Streaming: what happens, told as it happens
Mastodon's streaming API: /api/v1/streaming as a WebSocket (streams
subscribed in the URL or by message) and /api/v1/streaming/{stream} as
server-sent events, with health and the URL advertised. The user stream
tells posts reaching the persona's home (not those an exclusive list keeps
apart, which its list stream tells), notifications, edits and deletions;
public, hashtag and list streams tell what belongs in them. An in-process
hub carries ids only; each connection maps a post or a notification for its
own persona as it sends it, so nothing it may not see, or whose author it
blocked or muted, goes out. A deletion reaches only the streams that showed
the post. The token comes as access_token, header or WebSocket protocol.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
b274ce1268
commit
9268968fd4
14 files changed
+650
-30
No files matched your search
@@ -16,7 +16,7 @@ namespace PrivaPub.Domain.Social
|
||||
return;
|
||||
try
|
||||
{
|
||||
await DB.Default.SaveAsync(new Notification
|
||||
var notification = new Notification
|
||||
{
|
||||
AvatarId = avatarId,
|
||||
Type = type,
|
||||
@@ -26,7 +26,11 @@ namespace PrivaPub.Domain.Social
|
||||
Emoji = emoji,
|
||||
EmojiURL = emojiUrl,
|
||||
DedupeKey = emoji == default ? $"{type}|{avatarId}|{fromActorUri}|{postId}" : $"{type}|{avatarId}|{fromActorUri}|{postId}|{emoji}"
|
||||
}, token);
|
||||
};
|
||||
await DB.Default.SaveAsync(notification, token);
|
||||
var told = new Timelines.Streams.Event("notification", notification.ID);
|
||||
Timelines.Streams.ToPersona(avatarId, new Timelines.Streams.Key(Timelines.Streams.User), told);
|
||||
Timelines.Streams.ToPersona(avatarId, new Timelines.Streams.Key(Timelines.Streams.UserNotification), told);
|
||||
}
|
||||
catch (MongoWriteException ex) when (ex.WriteError?.Category == ServerErrorCategory.DuplicateKey)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user