getUserUriをUserEntityServiceに
This commit is contained in:
parent
70d34aa05c
commit
5115ff1466
16 changed files with 107 additions and 84 deletions
|
|
@ -11,7 +11,7 @@ import * as url from '@/misc/prelude/url.js';
|
|||
import type { Config } from '@/config.js';
|
||||
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||
import { QueueService } from '@/core/QueueService.js';
|
||||
import type { LocalUser, User } from '@/models/entities/User.js';
|
||||
import type { LocalUser, RemoteUser, User } from '@/models/entities/User.js';
|
||||
import { UserKeypairService } from '@/core/UserKeypairService.js';
|
||||
import type { Following } from '@/models/entities/Following.js';
|
||||
import { countIf } from '@/misc/prelude/array.js';
|
||||
|
|
@ -630,7 +630,7 @@ export class ActivityPubServerService {
|
|||
id: request.params.followee,
|
||||
host: Not(IsNull()),
|
||||
}),
|
||||
]);
|
||||
]) as [LocalUser | RemoteUser | null, LocalUser | RemoteUser | null];
|
||||
|
||||
if (follower == null || followee == null) {
|
||||
reply.code(404);
|
||||
|
|
@ -665,7 +665,7 @@ export class ActivityPubServerService {
|
|||
id: followRequest.followeeId,
|
||||
host: Not(IsNull()),
|
||||
}),
|
||||
]);
|
||||
]) as [LocalUser | RemoteUser | null, LocalUser | RemoteUser | null];
|
||||
|
||||
if (follower == null || followee == null) {
|
||||
reply.code(404);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { escapeAttribute, escapeValue } from '@/misc/prelude/xml.js';
|
|||
import type { User } from '@/models/entities/User.js';
|
||||
import * as Acct from '@/misc/acct.js';
|
||||
import { NodeinfoServerService } from './NodeinfoServerService.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import type { FindOptionsWhere } from 'typeorm';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
|
||||
|
|
@ -23,6 +24,7 @@ export class WellKnownServerService {
|
|||
private usersRepository: UsersRepository,
|
||||
|
||||
private nodeinfoServerService: NodeinfoServerService,
|
||||
private userEntityService: UserEntityService,
|
||||
) {
|
||||
//this.createServer = this.createServer.bind(this);
|
||||
}
|
||||
|
|
@ -130,7 +132,7 @@ fastify.get('/.well-known/change-password', async (request, reply) => {
|
|||
const self = {
|
||||
rel: 'self',
|
||||
type: 'application/activity+json',
|
||||
href: `${this.config.url}/users/${user.id}`,
|
||||
href: this.userEntityService.genLocalUserUri(user.id),
|
||||
};
|
||||
const profilePage = {
|
||||
rel: 'http://webfinger.net/rel/profile-page',
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ import { DI } from '@/di-symbols.js';
|
|||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
|
||||
import { LocalUser, RemoteUser } from '@/models/entities/User.js';
|
||||
|
||||
import { AccountMoveService } from '@/core/AccountMoveService.js';
|
||||
import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
|
||||
import { ApiLoggerService } from '@/server/api/ApiLoggerService.js';
|
||||
import { GetterService } from '@/server/api/GetterService.js';
|
||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
|
||||
import * as Acct from '@/misc/acct.js';
|
||||
|
||||
|
|
@ -81,6 +84,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
private accountMoveService: AccountMoveService,
|
||||
private getterService: GetterService,
|
||||
private apPersonService: ApPersonService,
|
||||
private userEntityService: UserEntityService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
// check parameter
|
||||
|
|
@ -97,8 +101,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
this.apiLoggerService.logger.warn(`failed to resolve remote user: ${e}`);
|
||||
throw new ApiError(meta.errors.noSuchUser);
|
||||
});
|
||||
const destination = await this.getterService.getUser(moveTo.id);
|
||||
const newUri = this.accountMoveService.getUserUri(destination);
|
||||
const destination = await this.getterService.getUser(moveTo.id) as LocalUser | RemoteUser;
|
||||
const newUri = this.userEntityService.getUserUri(destination);
|
||||
|
||||
// update local db
|
||||
await this.apPersonService.updatePerson(newUri);
|
||||
|
|
@ -106,7 +110,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
moveTo = await this.apPersonService.resolvePerson(newUri);
|
||||
|
||||
// make sure that the user has indicated the old account as an alias
|
||||
const fromUrl = `${this.config.url}/users/${me.id}`;
|
||||
const fromUrl = this.userEntityService.genLocalUserUri(me.id);
|
||||
let allowed = false;
|
||||
if (moveTo.alsoKnownAs) {
|
||||
for (const knownAs of moveTo.alsoKnownAs) {
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
});
|
||||
if (knownAs.id === _user.id) throw new ApiError(meta.errors.forbiddenToSetYourself);
|
||||
|
||||
const toUrl = this.accountMoveService.getUserUri(knownAs);
|
||||
const toUrl = this.userEntityService.getUserUri(knownAs);
|
||||
if (!toUrl) throw new ApiError(meta.errors.uriNull);
|
||||
|
||||
newAlsoKnownAs.add(toUrl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue