From d97fc9ce4ea19466fd77428724ffcab6fe001966 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 23 Jun 2021 13:42:02 +0900 Subject: カスタム絵文字インポート時もemojiAddedイベントを発行するように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints/admin/emoji/copy.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/server/api') diff --git a/src/server/api/endpoints/admin/emoji/copy.ts b/src/server/api/endpoints/admin/emoji/copy.ts index 1a784f4061..72c2b014a4 100644 --- a/src/server/api/endpoints/admin/emoji/copy.ts +++ b/src/server/api/endpoints/admin/emoji/copy.ts @@ -7,6 +7,7 @@ import { ApiError } from '../../../error'; import { DriveFile } from '../../../../../models/entities/drive-file'; import { ID } from '@/misc/cafy-id'; import uploadFromUrl from '../../../../../services/drive/upload-from-url'; +import { publishBroadcastStream } from '@/services/stream'; export const meta = { tags: ['admin'], @@ -57,7 +58,7 @@ export default define(meta, async (ps, me) => { throw new ApiError(); } - const copied = await Emojis.save({ + const copied = await Emojis.insert({ id: genId(), updatedAt: new Date(), name: emoji.name, @@ -66,10 +67,14 @@ export default define(meta, async (ps, me) => { url: driveFile.url, type: driveFile.type, fileId: driveFile.id, - }); + }).then(x => Emojis.findOneOrFail(x.identifiers[0])); await getConnection().queryResultCache!.remove(['meta_emojis']); + publishBroadcastStream('emojiAdded', { + emoji: await Emojis.pack(copied.id) + }); + return { id: copied.id }; -- cgit v1.2.3-freya From 28f7e48dc61164e574bf7e77012edd8319d33f14 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Jun 2021 23:33:50 +0900 Subject: improve type --- src/server/api/stream/channels/messaging.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/server/api') diff --git a/src/server/api/stream/channels/messaging.ts b/src/server/api/stream/channels/messaging.ts index 4c41dc820b..58427e2771 100644 --- a/src/server/api/stream/channels/messaging.ts +++ b/src/server/api/stream/channels/messaging.ts @@ -10,7 +10,7 @@ export default class extends Channel { public static requireCredential = true; private otherpartyId: string | null; - private otherparty?: User; + private otherparty: User | null; private groupId: string | null; private subCh: string; private typers: Record = {}; @@ -18,9 +18,9 @@ export default class extends Channel { @autobind public async init(params: any) { - this.otherpartyId = params.otherparty as string; - this.otherparty = await Users.findOne({ id: this.otherpartyId }); - this.groupId = params.group as string; + this.otherpartyId = params.otherparty; + this.otherparty = this.otherpartyId ? await Users.findOneOrFail({ id: this.otherpartyId }) : null; + this.groupId = params.group; // Check joining if (this.groupId) { -- cgit v1.2.3-freya From 49febe1764909428dc9c5217b25591dd4d98cf87 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 9 Jul 2021 01:07:55 +0900 Subject: Resolve #7165 --- src/server/api/common/read-notification.ts | 23 ++++++++++++++++++++--- src/services/note/read.ts | 5 +++++ 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/server/api') diff --git a/src/server/api/common/read-notification.ts b/src/server/api/common/read-notification.ts index f686446c5c..effa61e8b5 100644 --- a/src/server/api/common/read-notification.ts +++ b/src/server/api/common/read-notification.ts @@ -4,9 +4,6 @@ import { Notification } from '../../../models/entities/notification'; import { Notifications, Users } from '../../../models'; import { In } from 'typeorm'; -/** - * Mark notifications as read - */ export async function readNotification( userId: User['id'], notificationIds: Notification['id'][] @@ -19,6 +16,26 @@ export async function readNotification( isRead: true }); + post(userId); +} + +export async function readNotificationByQuery( + userId: User['id'], + query: Record +) { + // Update documents + await Notifications.update({ + ...query, + notifieeId: userId, + isRead: false + }, { + isRead: true + }); + + post(userId); +} + +async function post(userId: User['id']) { if (!await Users.getHasUnreadNotification(userId)) { // 全ての(いままで未読だった)通知を(これで)読みましたよというイベントを発行 publishMainStream(userId, 'readAllNotifications'); diff --git a/src/services/note/read.ts b/src/services/note/read.ts index 2bdb859476..a661c0a9d0 100644 --- a/src/services/note/read.ts +++ b/src/services/note/read.ts @@ -7,6 +7,7 @@ import { Channel } from '../../models/entities/channel'; import { checkHitAntenna } from '@/misc/check-hit-antenna'; import { getAntennas } from '@/misc/antenna-cache'; import { PackedNote } from '../../models/repositories/note'; +import { readNotificationByQuery } from '@/server/api/common/read-notification'; /** * Mark notes as read @@ -96,6 +97,10 @@ export default async function( publishMainStream(userId, 'readAllChannels'); } }); + + readNotificationByQuery(userId, { + noteId: In([...readMentions.map(n => n.id), ...readSpecifiedNotes.map(n => n.id)]), + }); } if (readAntennaNotes.length > 0) { -- cgit v1.2.3-freya From dc69490e3abdebf186e9b642c629ec888afc88d8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 15 Jul 2021 20:45:32 +0900 Subject: Refactoring --- src/client/components/post-form.vue | 2 +- src/client/components/user-info.vue | 2 +- src/client/components/user-preview.vue | 2 +- src/client/filters/user.ts | 2 +- src/client/pages/follow.vue | 2 +- src/client/pages/instance/abuses.vue | 2 +- src/client/pages/messaging/index.vue | 2 +- src/client/pages/messaging/messaging-room.vue | 2 +- src/client/pages/my-antennas/index.antenna.vue | 2 +- src/client/pages/room/room.vue | 2 +- src/client/pages/user/index.vue | 2 +- src/client/scripts/gen-search-query.ts | 2 +- src/client/scripts/get-user-menu.ts | 2 +- src/client/scripts/lookup-user.ts | 2 +- src/client/ui/chat/post-form.vue | 2 +- src/misc/acct.ts | 14 ++++++++++++++ src/misc/acct/parse.ts | 7 ------- src/misc/acct/render.ts | 5 ----- src/misc/acct/type.ts | 6 ------ src/queue/processors/db/import-following.ts | 2 +- src/queue/processors/db/import-user-lists.ts | 2 +- src/server/api/endpoints/pinned-users.ts | 2 +- src/server/api/limiter.ts | 2 +- src/server/web/index.ts | 2 +- src/server/well-known.ts | 3 +-- src/services/send-email-notification.ts | 4 ++-- src/tools/resync-remote-user.ts | 2 +- 27 files changed, 38 insertions(+), 43 deletions(-) create mode 100644 src/misc/acct.ts delete mode 100644 src/misc/acct/parse.ts delete mode 100644 src/misc/acct/render.ts delete mode 100644 src/misc/acct/type.ts (limited to 'src/server/api') diff --git a/src/client/components/post-form.vue b/src/client/components/post-form.vue index c5186577f3..13bbb3f9e5 100644 --- a/src/client/components/post-form.vue +++ b/src/client/components/post-form.vue @@ -61,7 +61,7 @@ import * as mfm from 'mfm-js'; import { host, url } from '@client/config'; import { erase, unique } from '../../prelude/array'; import { extractMentions } from '@/misc/extract-mentions'; -import getAcct from '@/misc/acct/render'; +import { getAcct } from '@/misc/acct'; import { formatTimeString } from '@/misc/format-time-string'; import { Autocomplete } from '@client/scripts/autocomplete'; import { noteVisibilities } from '../../types'; diff --git a/src/client/components/user-info.vue b/src/client/components/user-info.vue index 289e0f3c3f..402aa0d07c 100644 --- a/src/client/components/user-info.vue +++ b/src/client/components/user-info.vue @@ -29,7 +29,7 @@