This commit is contained in:
syuilo 2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View file

@ -65,7 +65,7 @@ class NotificationManager {
} else {
this.queue.push({
reason: reason,
target: notifiee
target: notifiee,
});
}
}
@ -74,7 +74,7 @@ class NotificationManager {
for (const x of this.queue) {
// ミュート情報を取得
const mentioneeMutes = await Mutings.find({
muterId: x.target
muterId: x.target,
});
const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId);
@ -83,7 +83,7 @@ class NotificationManager {
if (!mentioneesMutedUserIds.includes(this.notifier.id)) {
createNotification(x.target, x.reason, {
notifierId: this.notifier.id,
noteId: this.note.id
noteId: this.note.id,
});
}
}
@ -242,7 +242,7 @@ export default async (user: { id: User['id']; username: User['username']; host:
// Word mute
// TODO: cache
UserProfiles.find({
enableWordMute: true
enableWordMute: true,
}).then(us => {
for (const u of us) {
checkWordMute(note, { id: u.userId }, u.mutedWords).then(shouldMute => {
@ -450,7 +450,7 @@ function incRenoteCount(renote: Note) {
Notes.createQueryBuilder().update()
.set({
renoteCount: () => '"renoteCount" + 1',
score: () => '"score" + 1'
score: () => '"score" + 1',
})
.where('id = :id', { id: renote.id })
.execute();
@ -508,7 +508,7 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O
uri: u.uri,
url: url == null ? undefined : url,
username: u.username,
host: u.host
host: u.host,
} as IMentionedRemoteUsers[0];
}));
}
@ -528,7 +528,7 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O
votes: new Array(data.poll!.choices.length).fill(0),
noteVisibility: insert.visibility,
userId: user.id,
userHost: user.host
userHost: user.host,
});
await transactionalEntityManager.insert(Poll, poll);
@ -561,15 +561,15 @@ function index(note: Note) {
body: {
text: normalizeForSearch(note.text),
userId: note.userId,
userHost: note.userHost
}
userHost: note.userHost,
},
});
}
async function notifyToWatchersOfRenotee(renote: Note, user: { id: User['id']; }, nm: NotificationManager, type: NotificationType) {
const watchers = await NoteWatchings.find({
noteId: renote.id,
userId: Not(user.id)
userId: Not(user.id),
});
for (const watcher of watchers) {
@ -580,7 +580,7 @@ async function notifyToWatchersOfRenotee(renote: Note, user: { id: User['id']; }
async function notifyToWatchersOfReplyee(reply: Note, user: { id: User['id']; }, nm: NotificationManager) {
const watchers = await NoteWatchings.find({
noteId: reply.id,
userId: Not(user.id)
userId: Not(user.id),
});
for (const watcher of watchers) {
@ -600,7 +600,7 @@ async function createMentionedEvents(mentionedUsers: User[], note: Note, nm: Not
}
const detailPackedNote = await Notes.pack(note, u, {
detail: true
detail: true,
});
publishMainStream(u.id, 'mention', detailPackedNote);
@ -618,7 +618,7 @@ function incNotesCountOfUser(user: { id: User['id']; }) {
Users.createQueryBuilder().update()
.set({
updatedAt: new Date(),
notesCount: () => '"notesCount" + 1'
notesCount: () => '"notesCount" + 1',
})
.where('id = :id', { id: user.id })
.execute();

View file

@ -31,7 +31,7 @@ export default async function(user: User, note: Note, quiet = false) {
if (!quiet) {
publishNoteStream(note.id, 'deleted', {
deletedAt: deletedAt
deletedAt: deletedAt,
});
//#region ローカルの投稿なら削除アクティビティを配送
@ -41,7 +41,7 @@ export default async function(user: User, note: Note, quiet = false) {
// if deletd note is renote
if (note.renoteId && note.text == null && !note.hasPoll && (note.fileIds == null || note.fileIds.length == 0)) {
renote = await Notes.findOne({
id: note.renoteId
id: note.renoteId,
});
}
@ -76,7 +76,7 @@ export default async function(user: User, note: Note, quiet = false) {
await Notes.delete({
id: note.id,
userId: user.id
userId: user.id,
});
}
@ -116,14 +116,14 @@ async function getMentionedRemoteUsers(note: Note) {
// renote / quote
if (note.renoteUserId) {
where.push({
id: note.renoteUserId
id: note.renoteUserId,
});
}
if (where.length === 0) return [];
return await Users.find({
where
where,
}) as IRemoteUser[];
}

View file

@ -28,7 +28,7 @@ export default async function(user: User, note: Note, choice: number) {
// if already voted
const exist = await PollVotes.find({
noteId: note.id,
userId: user.id
userId: user.id,
});
if (poll.multiple) {
@ -45,7 +45,7 @@ export default async function(user: User, note: Note, choice: number) {
createdAt: new Date(),
noteId: note.id,
userId: user.id,
choice: choice
choice: choice,
});
// Increment votes count
@ -54,14 +54,14 @@ export default async function(user: User, note: Note, choice: number) {
publishNoteStream(note.id, 'pollVoted', {
choice: choice,
userId: user.id
userId: user.id,
});
// Notify
createNotification(note.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: choice
choice: choice,
});
// Fetch watchers
@ -74,7 +74,7 @@ export default async function(user: User, note: Note, choice: number) {
createNotification(watcher.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: choice
choice: choice,
});
}
});

View file

@ -35,7 +35,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
createdAt: new Date(),
noteId: note.id,
userId: user.id,
reaction
reaction,
};
// Create reaction
@ -66,7 +66,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
await Notes.createQueryBuilder().update()
.set({
reactions: () => sql,
score: () => '"score" + 1'
score: () => '"score" + 1',
})
.where('id = :id', { id: note.id })
.execute();
@ -79,22 +79,22 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
let emoji = await Emojis.findOne({
where: {
name: decodedReaction.name,
host: decodedReaction.host
host: decodedReaction.host,
},
select: ['name', 'host', 'url']
select: ['name', 'host', 'url'],
});
if (emoji) {
emoji = {
name: emoji.host ? `${emoji.name}@${emoji.host}` : `${emoji.name}@.`,
url: emoji.url
url: emoji.url,
} as any;
}
publishNoteStream(note.id, 'reacted', {
reaction: decodedReaction.reaction,
emoji: emoji,
userId: user.id
userId: user.id,
});
// リアクションされたユーザーがローカルユーザーなら通知を作成
@ -102,20 +102,20 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
createNotification(note.userId, 'reaction', {
notifierId: user.id,
noteId: note.id,
reaction: reaction
reaction: reaction,
});
}
// Fetch watchers
NoteWatchings.find({
noteId: note.id,
userId: Not(user.id)
userId: Not(user.id),
}).then(watchers => {
for (const watcher of watchers) {
createNotification(watcher.userId, 'reaction', {
notifierId: user.id,
noteId: note.id,
reaction: reaction
reaction: reaction,
});
}
});

View file

@ -40,7 +40,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note)
publishNoteStream(note.id, 'unreacted', {
reaction: decodeReaction(exist.reaction).reaction,
userId: user.id
userId: user.id,
});
//#region 配信

View file

@ -22,15 +22,15 @@ export default async function(
) {
const following = info?.following ? info.following : new Set<string>((await Followings.find({
where: {
followerId: userId
followerId: userId,
},
select: ['followeeId']
select: ['followeeId'],
})).map(x => x.followeeId));
const followingChannels = info?.followingChannels ? info.followingChannels : new Set<string>((await ChannelFollowings.find({
where: {
followerId: userId
followerId: userId,
},
select: ['followeeId']
select: ['followeeId'],
})).map(x => x.followeeId));
const myAntennas = (await getAntennas()).filter(a => a.userId === userId);
@ -70,7 +70,7 @@ export default async function(
NoteUnreads.count({
userId: userId,
isMentioned: true
isMentioned: true,
}).then(mentionsCount => {
if (mentionsCount === 0) {
// 全て既読になったイベントを発行
@ -80,7 +80,7 @@ export default async function(
NoteUnreads.count({
userId: userId,
isSpecified: true
isSpecified: true,
}).then(specifiedCount => {
if (specifiedCount === 0) {
// 全て既読になったイベントを発行
@ -90,7 +90,7 @@ export default async function(
NoteUnreads.count({
userId: userId,
noteChannelId: Not(IsNull())
noteChannelId: Not(IsNull()),
}).then(channelNoteCount => {
if (channelNoteCount === 0) {
// 全て既読になったイベントを発行
@ -106,16 +106,16 @@ export default async function(
if (readAntennaNotes.length > 0) {
await AntennaNotes.update({
antennaId: In(myAntennas.map(a => a.id)),
noteId: In(readAntennaNotes.map(n => n.id))
noteId: In(readAntennaNotes.map(n => n.id)),
}, {
read: true
read: true,
});
// TODO: まとめてクエリしたい
for (const antenna of myAntennas) {
const count = await AntennaNotes.count({
antennaId: antenna.id,
read: false
read: false,
});
if (count === 0) {

View file

@ -12,7 +12,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: {
//#region ミュートしているなら無視
// TODO: 現在の仕様ではChannelにミュートは適用されないのでよしなにケアする
const mute = await Mutings.find({
muterId: userId
muterId: userId,
});
if (mute.map(m => m.muteeId).includes(note.userId)) return;
//#endregion

View file

@ -5,6 +5,6 @@ import { Note } from '@/models/entities/note';
export default async (me: User['id'], note: Note) => {
await NoteWatchings.delete({
noteId: note.id,
userId: me
userId: me,
});
};

View file

@ -15,6 +15,6 @@ export default async (me: User['id'], note: Note) => {
createdAt: new Date(),
noteId: note.id,
userId: me,
noteUserId: note.userId
noteUserId: note.userId,
} as NoteWatching);
};