noteのread処理

This commit is contained in:
syuilo
2021-03-23 15:06:56 +09:00
parent 00bc097abb
commit 7e4a800352
10 changed files with 132 additions and 57 deletions

View File

@ -4,6 +4,7 @@ import { genId } from '../../../../misc/gen-id';
import { Antennas, UserLists, UserGroupJoinings } from '../../../../models';
import { ID } from '../../../../misc/cafy-id';
import { ApiError } from '../../error';
import { publishInternalEvent } from '../../../../services/stream';
export const meta = {
desc: {
@ -108,7 +109,7 @@ export default define(meta, async (ps, user) => {
}
}
const antenna = await Antennas.save({
const antenna = await Antennas.insert({
id: genId(),
createdAt: new Date(),
userId: user.id,
@ -123,7 +124,9 @@ export default define(meta, async (ps, user) => {
withReplies: ps.withReplies,
withFile: ps.withFile,
notify: ps.notify,
});
}).then(x => Antennas.findOneOrFail(x.identifiers[0]));
publishInternalEvent('antennaCreated', antenna);
return await Antennas.pack(antenna);
});

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { ApiError } from '../../error';
import { Antennas } from '../../../../models';
import { publishInternalEvent } from '../../../../services/stream';
export const meta = {
desc: {
@ -42,4 +43,6 @@ export default define(meta, async (ps, user) => {
}
await Antennas.delete(antenna.id);
publishInternalEvent('antennaDeleted', antenna);
});

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { ApiError } from '../../error';
import { Antennas, UserLists, UserGroupJoinings } from '../../../../models';
import { publishInternalEvent } from '../../../../services/stream';
export const meta = {
desc: {
@ -141,5 +142,7 @@ export default define(meta, async (ps, user) => {
notify: ps.notify,
});
publishInternalEvent('antennaUpdated', Antennas.findOneOrFail(antenna.id));
return await Antennas.pack(antenna.id);
});

View File

@ -168,17 +168,10 @@ export default class Connection {
if (note == null) return;
if (this.user && (note.userId !== this.user.id)) {
if (note.mentions && note.mentions.includes(this.user.id)) {
readNote(this.user.id, [note]);
} else if (note.visibleUserIds && note.visibleUserIds.includes(this.user.id)) {
readNote(this.user.id, [note]);
}
if (this.followingChannels.has(note.channelId)) {
// TODO
}
// TODO: アンテナの既読処理
readNote(this.user.id, [note], {
following: this.following,
followingChannels: this.followingChannels,
});
}
}