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

@ -10,7 +10,7 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: U
// 通知しない設定になっているか、自分自身の投稿なら既読にする
const read = !antenna.notify || (antenna.userId === noteUser.id);
AntennaNotes.save({
AntennaNotes.insert({
id: genId(),
antennaId: antenna.id,
noteId: note.id,

View File

@ -18,7 +18,7 @@ export default async function(blocker: User, blockee: User) {
unFollow(blockee, blocker)
]);
await Blockings.save({
await Blockings.insert({
id: genId(),
createdAt: new Date(),
blockerId: blocker.id,

View File

@ -22,7 +22,7 @@ export async function insertFollowingDoc(followee: User, follower: User) {
let alreadyFollowed = false;
await Followings.save({
await Followings.insert({
id: genId(),
createdAt: new Date(),
followerId: follower.id,

View File

@ -37,7 +37,7 @@ export async function addPinned(user: User, noteId: Note['id']) {
throw new IdentifiableError('23f0cf4e-59a3-4276-a91d-61a5891c1514', 'That note has already been pinned.');
}
await UserNotePinings.save({
await UserNotePinings.insert({
id: genId(),
createdAt: new Date(),
userId: user.id,

View File

@ -3,7 +3,7 @@ import { ModerationLogs } from '../models';
import { genId } from '../misc/gen-id';
export async function insertModerationLog(moderator: ILocalUser, type: string, info?: Record<string, any>) {
await ModerationLogs.save({
await ModerationLogs.insert({
id: genId(),
createdAt: new Date(),
userId: moderator.id,

View File

@ -14,7 +14,7 @@ import { renderActivity } from '../../remote/activitypub/renderer';
import { deliver } from '../../queue';
export async function createMessage(user: User, recipientUser: User | undefined, recipientGroup: UserGroup | undefined, text: string | undefined, file: DriveFile | null, uri?: string) {
const message = await MessagingMessages.save({
const message = {
id: genId(),
createdAt: new Date(),
fileId: file ? file.id : null,
@ -25,7 +25,9 @@ export async function createMessage(user: User, recipientUser: User | undefined,
isRead: false,
reads: [] as any[],
uri
} as MessagingMessage);
} as MessagingMessage;
await MessagingMessages.insert(message);
const messageObj = await MessagingMessages.pack(message);

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,

View File

@ -86,7 +86,7 @@ export async function updateHashtag(user: User, tag: string, isUserAttached = fa
}
} else {
if (isUserAttached) {
Hashtags.save({
Hashtags.insert({
id: genId(),
name: tag,
mentionedUserIds: [],
@ -103,7 +103,7 @@ export async function updateHashtag(user: User, tag: string, isUserAttached = fa
attachedRemoteUsersCount: Users.isRemoteUser(user) ? 1 : 0,
} as Hashtag);
} else {
Hashtags.save({
Hashtags.insert({
id: genId(),
name: tag,
mentionedUserIds: [user.id],

View File

@ -8,7 +8,7 @@ import { fetchProxyAccount } from '../../misc/fetch-proxy-account';
import createFollowing from '../following/create';
export async function pushUserToUserList(target: User, list: UserList) {
await UserListJoinings.save({
await UserListJoinings.insert({
id: genId(),
createdAt: new Date(),
userId: target.id,