mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(federation): ✨ Federate note deletions
This commit is contained in:
parent
431bc9c715
commit
88ad7178bf
4 changed files with 47 additions and 18 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue