Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import Channel from "../channel.js";
|
||||
import { Notes } from "../../../../models/index.js";
|
||||
import { isUserRelated } from "../../../../misc/is-user-related.js";
|
||||
import { IdentifiableError } from "../../../../misc/identifiable-error.js";
|
||||
export default class extends Channel {
|
||||
chName = "antenna";
|
||||
static shouldShare = false;
|
||||
static requireCredential = false;
|
||||
antennaId;
|
||||
constructor(id, connection){
|
||||
super(id, connection);
|
||||
this.onEvent = this.onEvent.bind(this);
|
||||
}
|
||||
async init(params) {
|
||||
this.antennaId = params.antennaId;
|
||||
// Subscribe stream
|
||||
this.subscriber.on(`antennaStream:${this.antennaId}`, this.onEvent);
|
||||
}
|
||||
async onEvent(data) {
|
||||
if (data.type === "note") {
|
||||
try {
|
||||
const note = await Notes.pack(data.body.id, this.user, {
|
||||
detail: true
|
||||
});
|
||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
||||
if (isUserRelated(note, this.muting)) return;
|
||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
||||
if (isUserRelated(note, this.blocking)) return;
|
||||
if (note.renote && !note.text && this.renoteMuting.has(note.userId)) return;
|
||||
this.connection.cacheNote(note);
|
||||
this.send("note", note);
|
||||
} catch (e) {
|
||||
if (e instanceof IdentifiableError && e.id === "9725d0ce-ba28-4dde-95a7-2cbb2c15de24") {
|
||||
// skip: note not visible to user
|
||||
return;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.send(data.type, data.body);
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off(`antennaStream:${this.antennaId}`, this.onEvent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user