This commit is contained in:
syuilo 2021-03-21 21:27:09 +09:00
parent 41b491fa7c
commit c4c20bee7c
28 changed files with 44 additions and 40 deletions

View file

@ -247,7 +247,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
for (const u of us) {
checkWordMute(note, { id: u.userId }, u.mutedWords).then(shouldMute => {
if (shouldMute) {
MutedNotes.save({
MutedNotes.insert({
id: genId(),
userId: u.userId,
noteId: note.id,

View file

@ -29,7 +29,7 @@ export default async function(user: User, note: Note, choice: number) {
}
// Create vote
await PollVotes.save({
await PollVotes.insert({
id: genId(),
createdAt: new Date(),
noteId: note.id,

View file

@ -18,17 +18,17 @@ export default async (user: User, note: Note, reaction?: string) => {
// TODO: cache
reaction = await toDbReaction(reaction, user.host);
let record: NoteReaction;
let record: NoteReaction = {
id: genId(),
createdAt: new Date(),
noteId: note.id,
userId: user.id,
reaction
};
// Create reaction
try {
record = await NoteReactions.save({
id: genId(),
createdAt: new Date(),
noteId: note.id,
userId: user.id,
reaction
});
await NoteReactions.insert(record);
} catch (e) {
if (isDuplicateKeyValueError(e)) {
record = await NoteReactions.findOneOrFail({

View file

@ -17,7 +17,7 @@ export default async function(userId: User['id'], note: Note, params: {
if (mute.map(m => m.muteeId).includes(note.userId)) return;
//#endregion
const unread = await NoteUnreads.save({
const unread = {
id: genId(),
noteId: note.id,
userId: userId,
@ -25,7 +25,9 @@ export default async function(userId: User['id'], note: Note, params: {
isMentioned: params.isMentioned,
noteChannelId: note.channelId,
noteUserId: note.userId,
});
};
await NoteUnreads.insert(unread);
// 2秒経っても既読にならなかったら「未読の投稿がありますよ」イベントを発行する
setTimeout(async () => {

View file

@ -10,7 +10,7 @@ export default async (me: User['id'], note: Note) => {
return;
}
await NoteWatchings.save({
await NoteWatchings.insert({
id: genId(),
createdAt: new Date(),
noteId: note.id,