From a973ca2a30ceb000d17c0aa9f4812ccb194137af Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 10 Jun 2025 03:59:35 +0800 Subject: [PATCH] core: use message.send(from, uids) --- packages/hydrooj/src/handler/contest.ts | 8 ++++---- packages/hydrooj/src/handler/discussion.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/hydrooj/src/handler/contest.ts b/packages/hydrooj/src/handler/contest.ts index 8f95c93cb..ca77e73e5 100644 --- a/packages/hydrooj/src/handler/contest.ts +++ b/packages/hydrooj/src/handler/contest.ts @@ -234,11 +234,11 @@ export class ContestProblemListHandler extends ContestDetailBaseHandler { await this.limitRate('add_discussion', 3600, 60); await contest.addClarification(domainId, tid, this.user._id, content, this.request.ip, subject); if (!this.user.own(this.tdoc)) { - await Promise.all([this.tdoc.owner, ...this.tdoc.maintainer].map((uid) => message.send(1, uid, JSON.stringify({ + await message.send(1, this.tdoc.maintainer.concat(this.tdoc.owner), JSON.stringify({ message: 'Contest {0} has a new clarification about {1}, please go to contest management to reply.', params: [this.tdoc.title, subject > 0 ? `#${this.tdoc.pids.indexOf(subject) + 1}` : 'the contest'], url: this.url('contest_manage', { tid }), - }), message.FLAG_I18N | message.FLAG_UNREAD))); + }), message.FLAG_I18N | message.FLAG_UNREAD); } this.back(); } @@ -462,11 +462,11 @@ export class ContestManagementHandler extends ContestManagementBaseHandler { const flag = contest.isOngoing(this.tdoc) ? message.FLAG_ALERT : message.FLAG_UNREAD; await Promise.all([ contest.addClarification(domainId, tid, 0, content, this.request.ip, subject), - ...uids.map((uid) => message.send(1, uid, JSON.stringify({ + message.send(1, uids, JSON.stringify({ message: 'Broadcast message from contest {0}:\n{1}', params: [this.tdoc.title, content], url: this.url('contest_problemlist', { tid }), - }), flag | message.FLAG_I18N)), + }), flag | message.FLAG_I18N), ]); } this.back(); diff --git a/packages/hydrooj/src/handler/discussion.ts b/packages/hydrooj/src/handler/discussion.ts index 2c8939258..fbed8ad50 100644 --- a/packages/hydrooj/src/handler/discussion.ts +++ b/packages/hydrooj/src/handler/discussion.ts @@ -238,7 +238,7 @@ class DiscussionDetailHandler extends DiscussionHandler { message: 'User {0} mentioned you in {1:link}', params: [this.user.uname, `/d/${domainId}${this.request.path}`], }); - await Promise.all(uids.map((i) => message.send(1, i, msg, message.FLAG_RICHTEXT | message.FLAG_UNREAD))); + await message.send(1, uids, msg, message.FLAG_RICHTEXT | message.FLAG_UNREAD); const drid = await discussion.addReply(domainId, did, this.user._id, content, this.request.ip); this.back({ drid }); } @@ -255,7 +255,7 @@ class DiscussionDetailHandler extends DiscussionHandler { message: 'User {0} mentioned you in {1:link}', params: [this.user.uname, `/d/${domainId}${this.request.path}`], }); - await Promise.all(uids.map((i) => message.send(1, i, msg, message.FLAG_RICHTEXT | message.FLAG_UNREAD))); + await message.send(1, uids, msg, message.FLAG_RICHTEXT | message.FLAG_UNREAD); await discussion.addTailReply(domainId, drid, this.user._id, content, this.request.ip); this.back(); }