|
|
|
@ -282,14 +282,26 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
|
|
|
|
|
|
|
|
|
@param('drid', Types.ObjectID)
|
|
|
|
|
async postDeleteReply(domainId: string, drid: ObjectID) {
|
|
|
|
|
const deleteBy = this.user.own(this.drdoc) ? 'self' : this.user.own(this.ddoc) ? 'DiscussionOwner' : 'Admin';
|
|
|
|
|
if (!(this.user.own(this.ddoc)
|
|
|
|
|
&& this.user.hasPerm(PERM.PERM_DELETE_DISCUSSION_REPLY_SELF_DISCUSSION))) {
|
|
|
|
|
if (!this.user.own(this.drdoc)) {
|
|
|
|
|
this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY);
|
|
|
|
|
} else this.checkPerm(PERM.PERM_DELETE_DISCUSSION_SELF);
|
|
|
|
|
}
|
|
|
|
|
const msg = JSON.stringify({
|
|
|
|
|
message: '{0} {1} delete your discussion reply {2} in "{3}"({4:link}).',
|
|
|
|
|
params: [
|
|
|
|
|
deleteBy,
|
|
|
|
|
this.user.uname,
|
|
|
|
|
this.drdoc.content.length > 10 ? `${this.drdoc.content.substring(0, 10)}...` : `${this.drdoc.content}`,
|
|
|
|
|
this.ddoc.title,
|
|
|
|
|
`/d/${domainId}${this.request.path}`,
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
await Promise.all([
|
|
|
|
|
discussion.delReply(domainId, drid),
|
|
|
|
|
deleteBy !== 'self' && message.send(1, this.drdoc.owner, msg, message.FLAG_RICHTEXT | message.FLAG_UNREAD),
|
|
|
|
|
oplog.log(this, 'discussion.reply.delete', this.drdoc),
|
|
|
|
|
]);
|
|
|
|
|
this.back();
|
|
|
|
@ -311,9 +323,20 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
|
|
|
|
@param('drid', Types.ObjectID)
|
|
|
|
|
@param('drrid', Types.ObjectID)
|
|
|
|
|
async postDeleteTailReply(domainId: string, drid: ObjectID, drrid: ObjectID) {
|
|
|
|
|
const deleteBy = this.user.own(this.drrdoc) ? 'self' : 'Admin';
|
|
|
|
|
if (!this.user.own(this.drrdoc)) this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY);
|
|
|
|
|
const msg = JSON.stringify({
|
|
|
|
|
message: 'Admin {0} delete your discussion tail reply {1} in "{2}"({3:link}).',
|
|
|
|
|
params: [
|
|
|
|
|
this.user.uname,
|
|
|
|
|
this.drrdoc.content.length > 10 ? `${this.drrdoc.content.substring(0, 10)}...` : this.drrdoc.content,
|
|
|
|
|
this.ddoc.title,
|
|
|
|
|
`/d/${domainId}${this.request.path}`,
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
await Promise.all([
|
|
|
|
|
discussion.delTailReply(domainId, drid, drrid),
|
|
|
|
|
deleteBy !== 'self' && message.send(1, this.drrdoc.owner, msg, message.FLAG_RICHTEXT | message.FLAG_UNREAD),
|
|
|
|
|
oplog.log(this, 'discussion.tailReply.delete', this.drrdoc),
|
|
|
|
|
]);
|
|
|
|
|
this.back();
|
|
|
|
@ -379,10 +402,19 @@ class DiscussionEditHandler extends DiscussionHandler {
|
|
|
|
|
|
|
|
|
|
@param('did', Types.ObjectID)
|
|
|
|
|
async postDelete(domainId: string, did: ObjectID) {
|
|
|
|
|
const deleteBy = this.user.own(this.ddoc) ? 'self' : 'Admin';
|
|
|
|
|
if (!this.user.own(this.ddoc)) this.checkPerm(PERM.PERM_DELETE_DISCUSSION);
|
|
|
|
|
else this.checkPerm(PERM.PERM_DELETE_DISCUSSION_SELF);
|
|
|
|
|
const msg = JSON.stringify({
|
|
|
|
|
message: 'Admin {0} delete your discussion "{1}".',
|
|
|
|
|
params: [
|
|
|
|
|
this.user.uname,
|
|
|
|
|
this.ddoc.title,
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
await Promise.all([
|
|
|
|
|
oplog.log(this, 'discussion.delete', this.ddoc),
|
|
|
|
|
deleteBy !== 'self' && message.send(1, this.ddoc.owner, msg, message.FLAG_RICHTEXT | message.FLAG_UNREAD),
|
|
|
|
|
discussion.del(domainId, did),
|
|
|
|
|
]);
|
|
|
|
|
this.response.body = { type: this.ddoc.parentType, parent: this.ddoc.parentId };
|
|
|
|
|