diff --git a/migration/1611354329133-followersUri.ts b/migration/1611354329133-followersUri.ts new file mode 100644 index 000000000..5114418ae --- /dev/null +++ b/migration/1611354329133-followersUri.ts @@ -0,0 +1,16 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class followersUri1611354329133 implements MigrationInterface { + name = 'followersUri1611354329133' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user" ADD "followersUri" varchar(512) DEFAULT NULL`); + await queryRunner.query(`COMMENT ON COLUMN "user"."followersUri" IS 'The URI of the user Follower Collection. It will be null if the origin of the user is local.'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`COMMENT ON COLUMN "user"."followersUri" IS 'The URI of the user Follower Collection. It will be null if the origin of the user is local.'`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "followersUri"`); + } + +} diff --git a/src/models/entities/user.ts b/src/models/entities/user.ts index ba2062fdb..91fbe35d9 100644 --- a/src/models/entities/user.ts +++ b/src/models/entities/user.ts @@ -201,6 +201,12 @@ export class User { }) public uri: string | null; + @Column('varchar', { + length: 512, nullable: true, + comment: 'The URI of the user Follower Collection. It will be null if the origin of the user is local.' + }) + public followersUri: string | null; + @Index({ unique: true }) @Column('char', { length: 16, nullable: true, unique: true, diff --git a/src/remote/activitypub/audience.ts b/src/remote/activitypub/audience.ts index 7cff678ae..85a70f828 100644 --- a/src/remote/activitypub/audience.ts +++ b/src/remote/activitypub/audience.ts @@ -86,8 +86,7 @@ function isPublic(id: string) { } function isFollowers(id: string, actor: IRemoteUser) { - return [ - `${actor.uri}/followers`, - // actor.followerUri, // TODO - ].includes(id); + return ( + id === (actor.followersUri || `${actor.uri}/followers`) + ); } diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index f0a312b21..8f1483ab4 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -159,6 +159,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise