mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-03-21 03:30:42 +00:00
Merge commit from fork
Co-authored-by: Julia Johannesen <197614925+juliajohannesen@users.noreply.github.com>
This commit is contained in:
@@ -129,6 +129,9 @@ export interface NoteEventTypes {
|
|||||||
type NoteStreamEventTypes = {
|
type NoteStreamEventTypes = {
|
||||||
[key in keyof NoteEventTypes]: {
|
[key in keyof NoteEventTypes]: {
|
||||||
id: MiNote['id'];
|
id: MiNote['id'];
|
||||||
|
userId: MiNote['userId'];
|
||||||
|
visibility: MiNote['visibility'];
|
||||||
|
visibleUserIds: MiNote['visibleUserIds'];
|
||||||
body: NoteEventTypes[key];
|
body: NoteEventTypes[key];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -378,9 +381,12 @@ export class GlobalEventService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public publishNoteStream<K extends keyof NoteEventTypes>(noteId: MiNote['id'], type: K, value?: NoteEventTypes[K]): void {
|
public publishNoteStream<K extends keyof NoteEventTypes>(note: MiNote, type: K, value?: NoteEventTypes[K]): void {
|
||||||
this.publish(`noteStream:${noteId}`, type, {
|
this.publish(`noteStream:${note.id}`, type, {
|
||||||
id: noteId,
|
id: note.id,
|
||||||
|
userId: note.userId,
|
||||||
|
visibility: note.visibility,
|
||||||
|
visibleUserIds: note.visibleUserIds,
|
||||||
body: value,
|
body: value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export class NoteDeleteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
this.globalEventService.publishNoteStream(note.id, 'deleted', {
|
this.globalEventService.publishNoteStream(note, 'deleted', {
|
||||||
deletedAt: deletedAt,
|
deletedAt: deletedAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export class PollService {
|
|||||||
const index = choice + 1; // In SQL, array index is 1 based
|
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}'`);
|
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,
|
choice: choice,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ export class ReactionService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
this.globalEventService.publishNoteStream(note.id, 'reacted', {
|
this.globalEventService.publishNoteStream(note, 'reacted', {
|
||||||
reaction: decodedReaction.reaction,
|
reaction: decodedReaction.reaction,
|
||||||
emoji: customEmoji != null ? {
|
emoji: customEmoji != null ? {
|
||||||
name: customEmoji.host ? `${customEmoji.name}@${customEmoji.host}` : `${customEmoji.name}@.`,
|
name: customEmoji.host ? `${customEmoji.name}@${customEmoji.host}` : `${customEmoji.name}@.`,
|
||||||
@@ -318,7 +318,7 @@ export class ReactionService {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.globalEventService.publishNoteStream(note.id, 'unreacted', {
|
this.globalEventService.publishNoteStream(note, 'unreacted', {
|
||||||
reaction: this.decodeReaction(exist.reaction).reaction,
|
reaction: this.decodeReaction(exist.reaction).reaction,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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
|
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}'`);
|
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,
|
choice: ps.choice,
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -206,6 +206,14 @@ export default class Connection {
|
|||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async onNoteStreamMessage(data: GlobalEvents['note']['payload']) {
|
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', {
|
this.sendMessageToWs('noteUpdated', {
|
||||||
id: data.body.id,
|
id: data.body.id,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
|
|||||||
Reference in New Issue
Block a user