mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ac_msg fallback support
This commit is contained in:
1 parent
9428efb156
commit
5980080302
9 files changed
+51
-9
No files matched your search
@@ -2,3 +2,7 @@
|
|||||||
为model.system添加缓存
|
为model.system添加缓存
|
||||||
bug修复
|
bug修复
|
||||||
修复discussion前端权限节点显示异常
|
修复discussion前端权限节点显示异常
|
||||||
|
web端运行脚本似乎异常
|
||||||
|
讨论回复通知
|
||||||
|
比赛举办者发布通知
|
||||||
|
举报功能
|
||||||
@@ -141,7 +141,7 @@ export function load() {
|
|||||||
),
|
),
|
||||||
db.collection('system').updateOne(
|
db.collection('system').updateOne(
|
||||||
{ _id: 'server.port' },
|
{ _id: 'server.port' },
|
||||||
{ $set: { value: listenPort } },
|
{ $set: { value: parseInt(listenPort, 10) } },
|
||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -336,6 +336,14 @@ class HomeMessagesHandler extends Handler {
|
|||||||
else throw new PermissionError();
|
else throw new PermissionError();
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@param('messageId', Types.ObjectID)
|
||||||
|
async postRead(domainId: string, messageId: ObjectID) {
|
||||||
|
const msg = await message.get(messageId);
|
||||||
|
if ([msg.from, msg.to].includes(this.user._id)) await message.setFlag(messageId, message.FLAG_UNREAD);
|
||||||
|
else throw new PermissionError();
|
||||||
|
this.back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomeMessagesConnectionHandler extends ConnectionHandler {
|
class HomeMessagesConnectionHandler extends ConnectionHandler {
|
||||||
|
|||||||
+2
-1
@@ -69,6 +69,7 @@ export interface Pdoc {
|
|||||||
data?: ObjectID | string,
|
data?: ObjectID | string,
|
||||||
hidden: boolean,
|
hidden: boolean,
|
||||||
config: string,
|
config: string,
|
||||||
|
acMsg?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Pdict = Dictionary<Pdoc>;
|
export type Pdict = Dictionary<Pdoc>;
|
||||||
@@ -150,7 +151,7 @@ export interface Mdoc {
|
|||||||
from: number,
|
from: number,
|
||||||
to: number,
|
to: number,
|
||||||
content: string,
|
content: string,
|
||||||
unread: boolean,
|
flag: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Userfile
|
// Userfile
|
||||||
|
|||||||
+8
-1
@@ -135,6 +135,13 @@ export function url(arg0: any, name: any) {
|
|||||||
return __url(arg0, name);
|
return __url(arg0, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ensureIndexes() {
|
||||||
|
return Promise.all([
|
||||||
|
collChunk.createIndex({ files_id: 1, n: 1 }, { unique: true }),
|
||||||
|
collFile.createIndex({ md5: 1 }),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
global.Hydro.model.file = {
|
global.Hydro.model.file = {
|
||||||
add, get, del, inc, dec, getMeta, getWithSecret, getMulti, getMetaDict, url,
|
add, get, del, inc, dec, getMeta, getWithSecret, getMulti, getMetaDict, url, ensureIndexes,
|
||||||
};
|
};
|
||||||
+19
-3
@@ -4,12 +4,15 @@ import * as db from '../service/db';
|
|||||||
|
|
||||||
const coll = db.collection('message');
|
const coll = db.collection('message');
|
||||||
|
|
||||||
export async function send(from: number, to: number, content: string): Promise<Mdoc> {
|
export const FLAG_UNREAD = 1;
|
||||||
|
export const FLAG_NOTIFICATION = 2;
|
||||||
|
|
||||||
|
export async function send(from: number, to: number, content: string, flag: number): Promise<Mdoc> {
|
||||||
const res = await coll.insertOne({
|
const res = await coll.insertOne({
|
||||||
from, to, content, unread: true,
|
from, to, content, flag: FLAG_UNREAD | flag,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
from, to, content, unread: true, _id: res.insertedId,
|
from, to, content, _id: res.insertedId, flag: FLAG_UNREAD | flag,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +30,15 @@ export async function getMany(query: any, sort: any, page: number, limit: number
|
|||||||
.toArray();
|
.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setFlag(messageId: ObjectID, flag: number) {
|
||||||
|
const result = await coll.findOneAndUpdate(
|
||||||
|
{ _id: messageId },
|
||||||
|
{ $bit: { flag: { xor: flag } } },
|
||||||
|
{ returnOriginal: false },
|
||||||
|
);
|
||||||
|
return result.value;
|
||||||
|
}
|
||||||
|
|
||||||
export async function del(_id: ObjectID) {
|
export async function del(_id: ObjectID) {
|
||||||
return await coll.deleteOne({ _id });
|
return await coll.deleteOne({ _id });
|
||||||
}
|
}
|
||||||
@@ -47,10 +59,14 @@ export function ensureIndexes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.model.message = {
|
global.Hydro.model.message = {
|
||||||
|
FLAG_UNREAD,
|
||||||
|
FLAG_NOTIFICATION,
|
||||||
|
|
||||||
count,
|
count,
|
||||||
get,
|
get,
|
||||||
getByUser,
|
getByUser,
|
||||||
del,
|
del,
|
||||||
|
setFlag,
|
||||||
getMany,
|
getMany,
|
||||||
getMulti,
|
getMulti,
|
||||||
send,
|
send,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export const pdocHidden: Pdoc = {
|
|||||||
data: null,
|
data: null,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
config: '',
|
config: '',
|
||||||
|
acMsg: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function add(
|
export async function add(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import Router from 'koa-router';
|
|||||||
import cache from 'koa-static-cache';
|
import cache from 'koa-static-cache';
|
||||||
import sockjs from 'sockjs';
|
import sockjs from 'sockjs';
|
||||||
import serialize from 'serialize-javascript';
|
import serialize from 'serialize-javascript';
|
||||||
|
import parse from 'yargs-parser';
|
||||||
import { lrucache } from '../utils';
|
import { lrucache } from '../utils';
|
||||||
import { User, DomainDoc } from '../interface';
|
import { User, DomainDoc } from '../interface';
|
||||||
import {
|
import {
|
||||||
@@ -31,8 +32,8 @@ import * as token from '../model/token';
|
|||||||
import * as opcount from '../model/opcount';
|
import * as opcount from '../model/opcount';
|
||||||
import hash from '../lib/hash.hydro';
|
import hash from '../lib/hash.hydro';
|
||||||
|
|
||||||
|
const argv = parse(process.argv.slice(2));
|
||||||
let enableLog = true;
|
let enableLog = true;
|
||||||
|
|
||||||
const app = new Koa();
|
const app = new Koa();
|
||||||
let server;
|
let server;
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
@@ -760,8 +761,8 @@ export async function start() {
|
|||||||
} else enableLog = false;
|
} else enableLog = false;
|
||||||
app.use(router.routes()).use(router.allowedMethods());
|
app.use(router.routes()).use(router.allowedMethods());
|
||||||
Route('notfound_handler', '*', Handler);
|
Route('notfound_handler', '*', Handler);
|
||||||
server.listen(port);
|
server.listen(argv.port || port);
|
||||||
console.log('Server listening at: %s', port);
|
console.log('Server listening at: %s', argv.port || port);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.service.server = {
|
global.Hydro.service.server = {
|
||||||
|
|||||||
@@ -97,6 +97,10 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{{ _('(None)') }}
|
{{ _('(None)') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if pdoc['acMsg'] and pdoc['psdoc']['status'] == STATUS.STATUS_ACCEPTED %}
|
||||||
|
<dt>{{ _('AC Message') }}</dt>
|
||||||
|
<dd>{{ pdoc['acMsg'] }}</dd>
|
||||||
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in new issue
Block a user