This commit is contained in:
undefined committed 2020-08-06 14:24:16 +08:00
1 parent 8389519249
commit a5886ecb99
37 files changed
+940 -162

No files matched your search

+2 -2
View File
@@ -118,7 +118,7 @@ class ContestBoardcastHandler extends ContestHandler {
const tdoc = await contest.get(domainId, tid);
if (tdoc.owner !== this.user._id) throw new PermissionError('Boardcast Message');
const tsdocs = await contest.getMultiStatus(domainId, { docId: tid }).toArray();
const uids = Array.from(new Set(tsdocs.map((tsdoc) => tsdoc.uid)));
const uids: number[] = Array.from(new Set(tsdocs.map((tsdoc) => tsdoc.uid)));
await Promise.all(
uids.map((uid) => message.send(this.user._id, uid, content, message.FLAG_ALERT)),
);
@@ -343,7 +343,7 @@ class ContestCodeHandler extends ContestHandler {
},
}).toArray();
for (const rdoc of rdocs) {
zip.addFile(`${rnames[rdoc._id]}.${rdoc.lang}`, rdoc.code);
zip.addFile(`${rnames[rdoc._id.toHexString()]}.${rdoc.lang}`, Buffer.from(rdoc.code));
}
await this.binary(zip.toBuffer(), `${tdoc.title}.zip`);
}
+1 -1
View File
@@ -395,7 +395,7 @@ class HomeworkCodeHandler extends HomeworkHandler {
},
}).toArray();
for (const rdoc of rdocs) {
zip.addFile(`${rnames[rdoc._id]}.${rdoc.lang}`, rdoc.code);
zip.addFile(`${rnames[rdoc._id.toHexString()]}.${rdoc.lang}`, Buffer.from(rdoc.code));
}
await this.binary(zip.toBuffer(), `${tdoc.title}.zip`);
}
+3 -2
View File
@@ -18,6 +18,7 @@ import { isEmail, isPassword, isUname } from '../lib/validator';
import { sendMail } from '../lib/mail';
import * as misc from '../lib/misc';
import paginate from '../lib/paginate';
import { User } from '../interface';
class UserLoginHandler extends Handler {
async get() {
@@ -201,12 +202,12 @@ class UserSearchHandler extends Handler {
@param('exectMatch', Types.Boolean)
async get(domainId: string, q: string, exactMatch = false) {
let udoc = await user.getById(domainId, parseInt(q, 10));
const udocs = udoc ? [udoc] : [];
const udocs: User[] = udoc ? [udoc] : [];
udoc = await user.getByUname(domainId, q);
if (udoc) udocs.push(udoc);
udoc = await user.getByEmail(domainId, q);
if (udoc) udocs.push(udoc);
if (!exactMatch) udocs.push(...await user.getPrefixList(q, 20));
if (!exactMatch) udocs.push(...await user.getPrefixList(domainId, q, 20));
for (const i in udocs) {
udocs[i].gravatar = misc.gravatar(udocs[i].gravatar || '');
}