Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com>
Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
This commit is contained in:
syuilo
2020-01-30 04:37:25 +09:00
committed by GitHub
parent a5955c1123
commit f6154dc0af
871 changed files with 26140 additions and 71950 deletions

View File

@ -9,6 +9,7 @@ import { EventEmitter } from 'events';
import { User } from '../../../models/entities/user';
import { App } from '../../../models/entities/app';
import { Users, Followings, Mutings } from '../../../models';
import { ApiError } from '../error';
/**
* Main stream connection
@ -83,8 +84,16 @@ export default class Connection {
// 呼び出し
call(endpoint, user, this.app, payload.data).then(res => {
this.sendMessageToWs(`api:${payload.id}`, { res });
}).catch(e => {
this.sendMessageToWs(`api:${payload.id}`, { e });
}).catch((e: ApiError) => {
this.sendMessageToWs(`api:${payload.id}`, {
error: {
message: e.message,
code: e.code,
id: e.id,
kind: e.kind,
...(e.info ? { info: e.info } : {})
}
});
});
}
@ -111,7 +120,7 @@ export default class Connection {
this.subscriber.on(`noteStream:${payload.id}`, this.onNoteStreamMessage);
}
if (payload.read && this.user) {
if (this.user) {
readNote(this.user.id, payload.id);
}
}