mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add PRIV_SEND_MESSAGE
This commit is contained in:
1 parent
be2b1c5524
commit
01d6d48c74
5 files changed
+12
-3
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.28.1",
|
"version": "2.28.2",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ class HomeMessagesHandler extends Handler {
|
|||||||
@param('uid', Types.Int)
|
@param('uid', Types.Int)
|
||||||
@param('content', Types.Content)
|
@param('content', Types.Content)
|
||||||
async postSend(domainId: string, uid: number, content: string) {
|
async postSend(domainId: string, uid: number, content: string) {
|
||||||
|
this.checkPriv(PRIV.PRIV_SEND_MESSAGE);
|
||||||
const udoc = await user.getById('system', uid);
|
const udoc = await user.getById('system', uid);
|
||||||
if (!udoc) throw new UserNotFoundError(uid);
|
if (!udoc) throw new UserNotFoundError(uid);
|
||||||
if (udoc.avatar) udoc.avatarUrl = avatar(udoc.avatar);
|
if (udoc.avatar) udoc.avatarUrl = avatar(udoc.avatar);
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ export const PRIV = {
|
|||||||
PRIV_VIEW_JUDGE_STATISTICS: 1 << 15,
|
PRIV_VIEW_JUDGE_STATISTICS: 1 << 15,
|
||||||
PRIV_UNLIMITED_ACCESS: 1 << 22,
|
PRIV_UNLIMITED_ACCESS: 1 << 22,
|
||||||
PRIV_VIEW_SYSTEM_NOTIFICATION: 1 << 23,
|
PRIV_VIEW_SYSTEM_NOTIFICATION: 1 << 23,
|
||||||
|
PRIV_SEND_MESSAGE: 1 << 24,
|
||||||
|
|
||||||
PRIV_ALL: -1,
|
PRIV_ALL: -1,
|
||||||
PRIV_DEFAULT: 0,
|
PRIV_DEFAULT: 0,
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ export class ProblemModel {
|
|||||||
const ddocs = await Promise.all(Object.keys(parsed).map((i) => domain.get(i)));
|
const ddocs = await Promise.all(Object.keys(parsed).map((i) => domain.get(i)));
|
||||||
const f = ddocs.filter((i) => !(
|
const f = ddocs.filter((i) => !(
|
||||||
i.share === '*'
|
i.share === '*'
|
||||||
|| (`,${i.share.replace(/,/g, ',').split(',').map((q) => q.trim()).join(',')},`).includes(`,${domainId},`)
|
|| (`,${(i.share || '').replace(/,/g, ',').split(',').map((q) => q.trim()).join(',')},`).includes(`,${domainId},`)
|
||||||
));
|
));
|
||||||
if (f.length) {
|
if (f.length) {
|
||||||
if (doThrow) throw new ProblemNotFoundError(f[0]._id, parsed[f[0]._id][0].pid);
|
if (doThrow) throw new ProblemNotFoundError(f[0]._id, parsed[f[0]._id][0].pid);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import * as discussion from './model/discussion';
|
|||||||
import domain from './model/domain';
|
import domain from './model/domain';
|
||||||
import * as document from './model/document';
|
import * as document from './model/document';
|
||||||
import * as system from './model/system';
|
import * as system from './model/system';
|
||||||
import { STATUS } from './model/builtin';
|
import { PRIV, STATUS } from './model/builtin';
|
||||||
import RecordModel from './model/record';
|
import RecordModel from './model/record';
|
||||||
import StorageModel from './model/storage';
|
import StorageModel from './model/storage';
|
||||||
import { size } from './lib/misc';
|
import { size } from './lib/misc';
|
||||||
@@ -398,6 +398,13 @@ const scripts: UpgradeScript[] = [
|
|||||||
await iterateAllDomain((ddoc) => RecordModel.coll.updateMany({ domainId: ddoc._id }, { $set: { pdomain: ddoc._id } }));
|
await iterateAllDomain((ddoc) => RecordModel.coll.updateMany({ domainId: ddoc._id }, { $set: { pdomain: ddoc._id } }));
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
async function _30_31() {
|
||||||
|
const _FRESH_INSTALL_IGNORE = 1;
|
||||||
|
await iterateAllUser(async (udoc) => {
|
||||||
|
await user.setPriv(udoc._id, udoc.priv | PRIV.PRIV_SEND_MESSAGE);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default scripts;
|
export default scripts;
|
||||||
Reference in new issue
Block a user