mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
This commit is contained in:
@@ -18,6 +18,9 @@
|
|||||||
"link": "Link",
|
"link": "Link",
|
||||||
"share": "Share",
|
"share": "Share",
|
||||||
"tools": "Tools",
|
"tools": "Tools",
|
||||||
|
"flag": "Flag",
|
||||||
|
|
||||||
|
"flag_title":"Flag this post for moderation",
|
||||||
|
|
||||||
"thread_tools.title": "Thread Tools",
|
"thread_tools.title": "Thread Tools",
|
||||||
"thread_tools.markAsUnreadForAll": "Mark Unread",
|
"thread_tools.markAsUnreadForAll": "Mark Unread",
|
||||||
|
|||||||
@@ -431,20 +431,26 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
|
|
||||||
$('#post-container').on('click', '.favourite', function() {
|
$('#post-container').on('click', '.favourite', function() {
|
||||||
var pid = $(this).parents('.post-row').attr('data-pid');
|
var pid = $(this).parents('.post-row').attr('data-pid');
|
||||||
var uid = $(this).parents('.post-row').attr('data-uid');
|
|
||||||
|
|
||||||
if ($(this).attr('data-favourited') == 'false') {
|
var method = $(this).attr('data-favourited') == 'false' ? 'posts.favourite' : 'posts.unfavourite';
|
||||||
socket.emit('posts.favourite', {
|
|
||||||
|
socket.emit(method, {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
room_id: app.currentRoom
|
room_id: app.currentRoom
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
socket.emit('posts.unfavourite', {
|
|
||||||
pid: pid,
|
|
||||||
room_id: app.currentRoom
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#post-container').on('click', '.flag', function() {
|
||||||
|
var pid = $(this).parents('.post-row').attr('data-pid');
|
||||||
|
|
||||||
|
socket.emit('posts.flag', pid, function(err) {
|
||||||
|
if(err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
app.alertSuccess('This post has been flagged for moderation.');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#post-container').on('shown.bs.dropdown', '.share-dropdown', function() {
|
$('#post-container').on('shown.bs.dropdown', '.share-dropdown', function() {
|
||||||
var pid = $(this).parents('.post-row').attr('data-pid');
|
var pid = $(this).parents('.post-row').attr('data-pid');
|
||||||
|
|||||||
@@ -66,8 +66,9 @@
|
|||||||
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<!-- IF @first -->
|
<!-- IF @first -->
|
||||||
<button class="btn btn-sm btn-default follow" type="button" title="Be notified of new replies in this topic"><i class="fa fa-eye"></i></button>
|
<button class="btn btn-sm btn-default follow" type="button" title="[[topic:notify_me]]"><i class="fa fa-eye"></i></button>
|
||||||
<!-- ENDIF @first -->
|
<!-- ENDIF @first -->
|
||||||
|
<button class="btn btn-sm btn-default flag" type="button" title="[[topic:flag_title]]"><i class="fa fa-flag-o"></i></button>
|
||||||
<button data-favourited="{posts.favourited}" class="favourite favourite-tooltip btn btn-sm btn-default <!-- IF posts.favourited --> btn-warning <!-- ENDIF posts.favourited -->" type="button">
|
<button data-favourited="{posts.favourited}" class="favourite favourite-tooltip btn btn-sm btn-default <!-- IF posts.favourited --> btn-warning <!-- ENDIF posts.favourited -->" type="button">
|
||||||
<span class="favourite-text">[[topic:favourite]]</span>
|
<span class="favourite-text">[[topic:favourite]]</span>
|
||||||
<span class="post_rep_{posts.pid}">{posts.reputation} </span>
|
<span class="post_rep_{posts.pid}">{posts.reputation} </span>
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
var posts = require('../posts'),
|
var async = require('async'),
|
||||||
|
nconf = require('nconf'),
|
||||||
|
|
||||||
|
posts = require('../posts'),
|
||||||
meta = require('../meta'),
|
meta = require('../meta'),
|
||||||
topics = require('../topics'),
|
topics = require('../topics'),
|
||||||
favourites = require('../favourites'),
|
favourites = require('../favourites'),
|
||||||
postTools = require('../postTools'),
|
postTools = require('../postTools'),
|
||||||
|
notifications = require('../notifications'),
|
||||||
|
groups = require('../groups'),
|
||||||
user = require('../user'),
|
user = require('../user'),
|
||||||
index = require('./index'),
|
index = require('./index'),
|
||||||
|
|
||||||
@@ -208,4 +213,36 @@ SocketPosts.getPidPage = function(socket, pid, callback) {
|
|||||||
posts.getPidPage(pid, callback);
|
posts.getPidPage(pid, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SocketPosts.flag = function(socket, pid, callback) {
|
||||||
|
var message = '',
|
||||||
|
path = '';
|
||||||
|
|
||||||
|
async.waterfall([
|
||||||
|
function(next) {
|
||||||
|
user.getUserField(socket.uid, 'username', next);
|
||||||
|
},
|
||||||
|
function(username, next) {
|
||||||
|
message = username + ' flagged a post.';
|
||||||
|
posts.getPostField(pid, 'tid', next);
|
||||||
|
},
|
||||||
|
function(tid, next) {
|
||||||
|
topics.getTopicField(tid, 'slug', next)
|
||||||
|
},
|
||||||
|
function(topicSlug, next) {
|
||||||
|
path = nconf.get('relative_path') + '/topic/' + topicSlug + '#' + pid;
|
||||||
|
groups.getByGroupName('administrators', {}, next);
|
||||||
|
},
|
||||||
|
function(adminGroup, next) {
|
||||||
|
|
||||||
|
notifications.create(message, path, 'post_flag:' + pid, function(nid) {
|
||||||
|
|
||||||
|
notifications.push(nid, adminGroup.members, function() {
|
||||||
|
console.log('derp');
|
||||||
|
next(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = SocketPosts;
|
module.exports = SocketPosts;
|
||||||
Reference in New Issue
Block a user