mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: discussion views (fix #69)
This commit is contained in:
1 parent
16fcd80a00
commit
2b8b9a776b
5 files changed
+29
-11
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.32.2",
|
"version": "2.32.3",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -187,6 +187,12 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
|||||||
if (drdoc.reply) uids.push(...drdoc.reply.map((drrdoc) => drrdoc.owner));
|
if (drdoc.reply) uids.push(...drdoc.reply.map((drrdoc) => drrdoc.owner));
|
||||||
}
|
}
|
||||||
const udict = await user.getList(domainId, uids);
|
const udict = await user.getList(domainId, uids);
|
||||||
|
if (!dsdoc.view) {
|
||||||
|
await Promise.all([
|
||||||
|
discussion.inc(domainId, did, 'views', 1),
|
||||||
|
discussion.setStatus(domainId, did, this.user._id, { view: true }),
|
||||||
|
]);
|
||||||
|
}
|
||||||
const path = [
|
const path = [
|
||||||
['Hydro', 'homepage'],
|
['Hydro', 'homepage'],
|
||||||
['discussion_main', 'discussion_main'],
|
['discussion_main', 'discussion_main'],
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import TaskModel from './task';
|
|||||||
import { DiscussionNodeNotFoundError, DocumentNotFoundError } from '../error';
|
import { DiscussionNodeNotFoundError, DocumentNotFoundError } from '../error';
|
||||||
import { DiscussionReplyDoc, DiscussionTailReplyDoc, Document } from '../interface';
|
import { DiscussionReplyDoc, DiscussionTailReplyDoc, Document } from '../interface';
|
||||||
import { buildProjection } from '../utils';
|
import { buildProjection } from '../utils';
|
||||||
|
import { NumberKeys } from '../typeutils';
|
||||||
import * as bus from '../service/bus';
|
import * as bus from '../service/bus';
|
||||||
|
|
||||||
export interface DiscussionDoc extends Document { }
|
export interface DiscussionDoc extends Document { }
|
||||||
@@ -112,6 +113,12 @@ export function edit(
|
|||||||
return document.set(domainId, document.TYPE_DISCUSSION, did, payload);
|
return document.set(domainId, document.TYPE_DISCUSSION, did, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function inc(
|
||||||
|
domainId: string, did: ObjectID, key: NumberKeys<DiscussionDoc>, value: number,
|
||||||
|
): Promise<DiscussionDoc | null> {
|
||||||
|
return document.inc(domainId, document.TYPE_DISCUSSION, did, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
export function del(domainId: string, did: ObjectID): Promise<never> {
|
export function del(domainId: string, did: ObjectID): Promise<never> {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
document.deleteOne(domainId, document.TYPE_DISCUSSION, did),
|
document.deleteOne(domainId, document.TYPE_DISCUSSION, did),
|
||||||
@@ -221,6 +228,10 @@ export function getStatus(domainId: string, did: ObjectID, uid: number) {
|
|||||||
return document.getStatus(domainId, document.TYPE_DISCUSSION, did, uid);
|
return document.getStatus(domainId, document.TYPE_DISCUSSION, did, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setStatus(domainId: string, did: ObjectID, uid: number, $set) {
|
||||||
|
return document.setStatus(domainId, document.TYPE_DISCUSSION, did, uid, $set);
|
||||||
|
}
|
||||||
|
|
||||||
export function addNode(domainId: string, _id: string, category: string, args: any = {}) {
|
export function addNode(domainId: string, _id: string, category: string, args: any = {}) {
|
||||||
return document.add(
|
return document.add(
|
||||||
domainId, category, 1, document.TYPE_DISCUSSION_NODE,
|
domainId, category, 1, document.TYPE_DISCUSSION_NODE,
|
||||||
@@ -327,6 +338,7 @@ global.Hydro.model.discussion = {
|
|||||||
|
|
||||||
add,
|
add,
|
||||||
get,
|
get,
|
||||||
|
inc,
|
||||||
edit,
|
edit,
|
||||||
del,
|
del,
|
||||||
count,
|
count,
|
||||||
@@ -344,6 +356,7 @@ global.Hydro.model.discussion = {
|
|||||||
react,
|
react,
|
||||||
setStar,
|
setStar,
|
||||||
getStatus,
|
getStatus,
|
||||||
|
setStatus,
|
||||||
addNode,
|
addNode,
|
||||||
getNode,
|
getNode,
|
||||||
getNodes,
|
getNodes,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.16.1",
|
"version": "4.16.2",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
{{ vnode['title'] }}
|
{{ vnode['title'] }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li><h2>{{ ddoc.title }}</h2></li>
|
||||||
<li>
|
<li>
|
||||||
{{ user.render_inline(udict[ddoc.owner]) }}
|
{{ user.render_inline(udict[ddoc.owner]) }}
|
||||||
@
|
@
|
||||||
@@ -30,13 +31,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<ul class="section__footer supplementary dot list">
|
<ul class="section__footer supplementary dot list">
|
||||||
{% if handler.user.hasPerm(perm.PERM_EDIT_DISCUSSION) or (handler.user.own(ddoc) and handler.user.hasPerm(perm.PERM_EDIT_DISCUSSION_SELF)) %}
|
{% if handler.user.hasPerm(perm.PERM_EDIT_DISCUSSION) or (handler.user.own(ddoc) and handler.user.hasPerm(perm.PERM_EDIT_DISCUSSION_SELF)) %}
|
||||||
<li>
|
<li><a href="{{ url('discussion_edit', did=ddoc.docId) }}">
|
||||||
<a href="{{ url('discussion_edit', did=ddoc.docId) }}"><span class="icon icon-edit"></span> {{ _('Edit') }}</a>
|
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
||||||
</li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
<li>{{ _('{0} views').format(ddoc.views) }}</li>
|
||||||
{{ _('{0} views').format(ddoc.views) }}
|
|
||||||
</li>
|
|
||||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||||
<li><form class="form--inline" method="post">
|
<li><form class="form--inline" method="post">
|
||||||
<input type="hidden" name="operation" value="{% if not dsdoc['star'] %}star{% else %}unstar{% endif %}">
|
<input type="hidden" name="operation" value="{% if not dsdoc['star'] %}star{% else %}unstar{% endif %}">
|
||||||
@@ -47,9 +46,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</form></li>
|
</form></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
<li><a href="{{ url('wiki_help', anchor='contact') }}">
|
||||||
<a href="{{ url('wiki_help', anchor='contact') }}"><span class="icon icon-warning"></span> {{ _('Report') }}</a>
|
<span class="icon icon-warning"></span> {{ _('Report') }}
|
||||||
</li>
|
</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
|
|||||||
Reference in new issue
Block a user