feat(federation): Federate note deletions

This commit is contained in:
Jesse Wierzbinski 2024-06-05 19:25:49 -10:00
parent 431bc9c715
commit 88ad7178bf
No known key found for this signature in database
4 changed files with 47 additions and 18 deletions

View file

@ -520,29 +520,33 @@ export class User {
data.endpoints ||
data.isDiscoverable
) {
// Get followers
const followers = await User.manyFromSql(
and(
sql`EXISTS (SELECT 1 FROM "Relationships" WHERE "Relationships"."subjectId" = ${this.id} AND "Relationships"."ownerId" = ${Users.id} AND "Relationships"."following" = true)`,
isNotNull(Users.instanceId),
),
);
for (const follower of followers) {
const federationRequest = await objectToInboxRequest(
this.toLysand(),
this,
follower,
);
// FIXME: Add to new queue system when it's implemented
fetch(federationRequest);
}
await this.federateToFollowers(this.toLysand());
}
return this;
}
async federateToFollowers(object: typeof EntityValidator.$Entity) {
// Get followers
const followers = await User.manyFromSql(
and(
sql`EXISTS (SELECT 1 FROM "Relationships" WHERE "Relationships"."subjectId" = ${this.id} AND "Relationships"."ownerId" = ${Users.id} AND "Relationships"."following" = true)`,
isNotNull(Users.instanceId),
),
);
for (const follower of followers) {
const federationRequest = await objectToInboxRequest(
object,
this,
follower,
);
// FIXME: Add to new queue system when it's implemented
fetch(federationRequest);
}
}
toAPI(isOwnAccount = false): APIAccount {
const user = this.getUser();
return {