This commit is contained in:
Barış Soner Uşaklı
2017-03-23 10:58:17 +03:00
parent 4b3dcd1a02
commit fe27d40ff6
7 changed files with 115 additions and 12 deletions

View File

@@ -316,7 +316,7 @@ SocketUser.getUserByEmail = function (socket, email, callback) {
};
SocketUser.setModerationNote = function (socket, data, callback) {
if (!socket.uid || !data || !data.uid) {
if (!socket.uid || !data || !data.uid || !data.note) {
return callback(new Error('[[error:invalid-data]]'));
}
@@ -335,11 +335,13 @@ SocketUser.setModerationNote = function (socket, data, callback) {
if (!allowed) {
return next(new Error('[[error:no-privileges]]'));
}
if (data.note) {
user.setUserField(data.uid, 'moderationNote', data.note, next);
} else {
db.deleteObjectField('user:' + data.uid, 'moderationNote', next);
}
var note = {
uid: socket.uid,
note: data.note,
timestamp: Date.now(),
};
db.sortedSetAdd('uid:' + data.uid + ':moderation:notes', note.timestamp, JSON.stringify(note), next);
},
], callback);
};