Merge commit from fork

Co-authored-by: Julia Johannesen <197614925+juliajohannesen@users.noreply.github.com>
This commit is contained in:
syuilo
2026-03-09 08:14:12 +09:00
committed by GitHub
parent b5d399674a
commit a07dc589e7
6 changed files with 22 additions and 8 deletions

View File

@@ -129,6 +129,9 @@ export interface NoteEventTypes {
type NoteStreamEventTypes = {
[key in keyof NoteEventTypes]: {
id: MiNote['id'];
userId: MiNote['userId'];
visibility: MiNote['visibility'];
visibleUserIds: MiNote['visibleUserIds'];
body: NoteEventTypes[key];
};
};
@@ -378,9 +381,12 @@ export class GlobalEventService {
}
@bindThis
public publishNoteStream<K extends keyof NoteEventTypes>(noteId: MiNote['id'], type: K, value?: NoteEventTypes[K]): void {
this.publish(`noteStream:${noteId}`, type, {
id: noteId,
public publishNoteStream<K extends keyof NoteEventTypes>(note: MiNote, type: K, value?: NoteEventTypes[K]): void {
this.publish(`noteStream:${note.id}`, type, {
id: note.id,
userId: note.userId,
visibility: note.visibility,
visibleUserIds: note.visibleUserIds,
body: value,
});
}

View File

@@ -68,7 +68,7 @@ export class NoteDeleteService {
}
if (!quiet) {
this.globalEventService.publishNoteStream(note.id, 'deleted', {
this.globalEventService.publishNoteStream(note, 'deleted', {
deletedAt: deletedAt,
});

View File

@@ -83,7 +83,7 @@ export class PollService {
const index = choice + 1; // In SQL, array index is 1 based
await this.pollsRepository.query(`UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`);
this.globalEventService.publishNoteStream(note.id, 'pollVoted', {
this.globalEventService.publishNoteStream(note, 'pollVoted', {
choice: choice,
userId: user.id,
});

View File

@@ -244,7 +244,7 @@ export class ReactionService {
},
});
this.globalEventService.publishNoteStream(note.id, 'reacted', {
this.globalEventService.publishNoteStream(note, 'reacted', {
reaction: decodedReaction.reaction,
emoji: customEmoji != null ? {
name: customEmoji.host ? `${customEmoji.name}@${customEmoji.host}` : `${customEmoji.name}@.`,
@@ -318,7 +318,7 @@ export class ReactionService {
.execute();
}
this.globalEventService.publishNoteStream(note.id, 'unreacted', {
this.globalEventService.publishNoteStream(note, 'unreacted', {
reaction: this.decodeReaction(exist.reaction).reaction,
userId: user.id,
});

View File

@@ -155,7 +155,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const index = ps.choice + 1; // In SQL, array index is 1 based
await this.pollsRepository.query(`UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`);
this.globalEventService.publishNoteStream(note.id, 'pollVoted', {
this.globalEventService.publishNoteStream(note, 'pollVoted', {
choice: ps.choice,
userId: me.id,
});

View File

@@ -206,6 +206,14 @@ export default class Connection {
@bindThis
private async onNoteStreamMessage(data: GlobalEvents['note']['payload']) {
if (data.body.visibility === 'specified' && !data.body.visibleUserIds.includes(this.user!.id)) {
return;
}
if (data.body.visibility === 'followers' && !Object.hasOwn(this.following, data.body.userId)) {
return;
}
this.sendMessageToWs('noteUpdated', {
id: data.body.id,
type: data.type,