[backend/core] Only deliver create/update activities to remote users, unify DeliverToConditionalAsync calls
This commit is contained in:
parent
46eda9b4c0
commit
3c96d98932
2 changed files with 19 additions and 18 deletions
|
@ -65,6 +65,22 @@ public class ActivityDeliverService(
|
|||
await DeliverToAsync(activity, actor, recipients);
|
||||
}
|
||||
|
||||
public async Task DeliverToConditionalAsync(
|
||||
ASActivity activity, User actor, Note note, IEnumerable<string> recipientIds
|
||||
)
|
||||
{
|
||||
var recipients = await db.Users
|
||||
.Where(p => recipientIds.Contains(p.Id))
|
||||
.Where(p => p.IsRemoteUser)
|
||||
.Select(p => new User { Id = p.Id })
|
||||
.ToListAsync();
|
||||
|
||||
if (note.Visibility == Note.NoteVisibility.Specified)
|
||||
await DeliverToAsync(activity, note.User, recipients.ToArray());
|
||||
else
|
||||
await DeliverToFollowersAsync(activity, note.User, recipients);
|
||||
}
|
||||
|
||||
public async Task DeliverToAsync(ASActivity activity, User actor, string recipientInbox)
|
||||
{
|
||||
logger.LogDebug("Queuing deliver-to-inbox job for activity {id}", activity.Id);
|
||||
|
|
|
@ -436,15 +436,8 @@ public class NoteService(
|
|||
? [note.Renote.User.Id]
|
||||
: [];
|
||||
|
||||
var recipients = await db.Users
|
||||
.Where(p => mentionedUserIds.Concat(additionalUserIds).Contains(p.Id))
|
||||
.Select(p => new User { Id = p.Id })
|
||||
.ToListAsync();
|
||||
|
||||
if (note.Visibility == Note.NoteVisibility.Specified)
|
||||
await deliverSvc.DeliverToAsync(activity, data.User, recipients.ToArray());
|
||||
else
|
||||
await deliverSvc.DeliverToFollowersAsync(activity, data.User, recipients);
|
||||
var recipientIds = mentionedUserIds.Concat(additionalUserIds);
|
||||
await deliverSvc.DeliverToConditionalAsync(activity, note.User, note, recipientIds);
|
||||
|
||||
return note;
|
||||
}
|
||||
|
@ -696,15 +689,7 @@ public class NoteService(
|
|||
var obj = await noteRenderer.RenderAsync(note, mentions);
|
||||
var activity = ActivityPub.ActivityRenderer.RenderUpdate(obj, actor);
|
||||
|
||||
var recipients = await db.Users.Where(p => mentionedUserIds.Contains(p.Id))
|
||||
.Select(p => new User { Id = p.Id })
|
||||
.ToListAsync();
|
||||
|
||||
if (note.Visibility == Note.NoteVisibility.Specified)
|
||||
await deliverSvc.DeliverToAsync(activity, note.User, recipients.ToArray());
|
||||
else
|
||||
await deliverSvc.DeliverToFollowersAsync(activity, note.User, recipients);
|
||||
|
||||
await deliverSvc.DeliverToConditionalAsync(activity, note.User, note, mentionedUserIds);
|
||||
return note;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue