- Blocks are per persona and never federate (a Block activity would tell
the other server who blocked whom): the blocked account is removed as a
follower, with a Reject{Follow} if it is remote, unfollowed, cleared from
home and notifications, and refused with Reject if it follows again.
- Mutes (optionally timed, optionally sparing notifications) and per-
persona domain blocks keep authors out of home timelines, notifications
and every status list the API returns; the boosts of a hidden author's
posts are hidden too.
- Bookmarks and pins (at most five, public or unlisted, own posts) with
their Mastodon endpoints and flags; pinned posts are the actor's
`featured` collection at /trophies, and `featuredTags` points at
/tattoos.
- Reports: /api/v1/reports stores the report and, when forwarding to a
remote account, sends Flag from the instance actor, so the reporting
persona is never named to the other server. An inbound Flag about a local
persona or its posts becomes a report; moderators list and resolve them
under /clientapi/moderator/reports.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
35 lines
938 B
C#
35 lines
938 B
C#
using MongoDB.Driver;
|
|
using MongoDB.Entities;
|
|
|
|
using PrivaPub.Models.Social;
|
|
|
|
namespace PrivaPub.Domain.Social
|
|
{
|
|
public static class Notifications
|
|
{
|
|
public static async Task Add(string avatarId, NotificationType type, string fromAccountId, string fromActorUri, string postId,
|
|
CancellationToken token)
|
|
{
|
|
if (string.IsNullOrEmpty(avatarId) || avatarId == fromAccountId)
|
|
return;
|
|
if ((await Relationships.Hidden.AuthorsHiddenFrom(avatarId, new[] { fromActorUri }, forNotifications: true, token)).Count > 0)
|
|
return;
|
|
try
|
|
{
|
|
await DB.Default.SaveAsync(new Notification
|
|
{
|
|
AvatarId = avatarId,
|
|
Type = type,
|
|
FromAccountId = fromAccountId,
|
|
FromActorURI = fromActorUri,
|
|
PostId = postId,
|
|
DedupeKey = $"{type}|{avatarId}|{fromActorUri}|{postId}"
|
|
}, token);
|
|
}
|
|
catch (MongoWriteException ex) when (ex.WriteError?.Category == ServerErrorCategory.DuplicateKey)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|