mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-03 08:21:07 +00:00
Added method for letting an admin unhide a flagged message
This commit is contained in:
parent
f9c00003f3
commit
38cd0e8de1
5 changed files with 39 additions and 0 deletions
|
|
@ -146,6 +146,14 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||
$scope.$close();
|
||||
});
|
||||
}
|
||||
$scope.clearFlagCount = function(message, groupId) {
|
||||
console.log("Heeey");
|
||||
Groups.Group.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||
message.flagCount = 0;
|
||||
Notification.text("Flags cleared");
|
||||
$scope.$close();
|
||||
});
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ angular.module('groupServices', ['ngResource']).
|
|||
postChat: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/chat'},
|
||||
deleteChatMessage: {method: "DELETE", url: ApiUrlService.get() + '/api/v2/groups/:gid/chat/:messageId'},
|
||||
flagChatMessage: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/chat/:messageId/flag'},
|
||||
clearFlagCount: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/chat/:messageId/clearflags'},
|
||||
join: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/join'},
|
||||
leave: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/leave'},
|
||||
invite: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/invite'},
|
||||
|
|
|
|||
|
|
@ -285,6 +285,23 @@ api.flagChatMessage = function(req, res, next){
|
|||
});
|
||||
}
|
||||
|
||||
api.clearFlagCount = function(req, res, next){
|
||||
var user = res.locals.user
|
||||
var group = res.locals.group;
|
||||
var message = _.find(group.chat, {id: req.params.mid});
|
||||
|
||||
if(!message) return res.json(404, {err: "Message not found!"});
|
||||
|
||||
if(user.contributor.admin)
|
||||
message.flagCount = 0;
|
||||
|
||||
group.markModified('chat');
|
||||
group.save(function(err,_saved){
|
||||
if(err) return next(err);
|
||||
return res.send(204);
|
||||
});
|
||||
}
|
||||
|
||||
api.seenMessage = function(req,res,next){
|
||||
// Skip the auth step, we want this to be fast. If !found with uuid/token, then it just doesn't save
|
||||
// Check for req.params.gid to exist
|
||||
|
|
|
|||
|
|
@ -588,6 +588,17 @@ module.exports = (swagger, v2) ->
|
|||
middleware: [auth.auth, i18n.getUserLanguage, groups.attachGroup]
|
||||
action: groups.flagChatMessage
|
||||
|
||||
"/groups/{gid}/chat/{mid}/clearflags":
|
||||
spec:
|
||||
method: 'POST'
|
||||
description: "Clear flag count from message and unhide it"
|
||||
parameters: [
|
||||
path 'gid','Group id','string'
|
||||
path 'mid','Message id','string'
|
||||
]
|
||||
middleware: [auth.auth, i18n.getUserLanguage, groups.attachGroup]
|
||||
action: groups.clearFlagCount
|
||||
|
||||
# ---------------------------------
|
||||
# Members
|
||||
# ---------------------------------
|
||||
|
|
|
|||
|
|
@ -98,5 +98,7 @@ script(type='text/ng-template', id='modals/abuse-flag.html')
|
|||
markdown(ng-model="abuseObject.text")
|
||||
p!=env.t('abuseFlagModalBody', {firstLinkStart: "<a href='/static/community-guidelines' target='_blank'>", secondLinkStart: "<a href='/static/terms' target='_blank'>", linkEnd: "</a>"})
|
||||
.modal-footer
|
||||
button.pull-left.btn.btn-primary(ng-click='clearFlagCount(abuseObject, groupId)', ng-if='user.contributor.admin && abuseObject.flagCount >= 2')
|
||||
| Reset Flag Count
|
||||
button.btn.btn-primary(ng-click='$close()')=env.t('cancel')
|
||||
button.btn.btn-default(ng-click='reportAbuse(user, abuseObject, groupId)')=env.t("abuseFlagModalButton")
|
||||
|
|
|
|||
Loading…
Reference in a new issue