favouriting no longer affects reputation

v1.18.x
psychobunny 11 years ago
parent 6ffab73784
commit d35dc2d89b

@ -167,24 +167,14 @@ var async = require('async'),
} }
posts.getPostFields(pid, ['uid', 'timestamp'], function (err, postData) { posts.getPostFields(pid, ['uid', 'timestamp'], function (err, postData) {
Favourites.hasFavourited(pid, uid, function (err, hasFavourited) { Favourites.hasFavourited(pid, uid, function (err, hasFavourited) {
if (!hasFavourited) { if (!hasFavourited) {
db.sortedSetAdd('uid:' + uid + ':favourites', postData.timestamp, pid); db.sortedSetAdd('uid:' + uid + ':favourites', postData.timestamp, pid);
db.setAdd('pid:' + pid + ':users_favourited', uid, function(err) { db.setAdd('pid:' + pid + ':users_favourited', uid, function(err) {
db.setCount('pid:' + pid + ':users_favourited', function(err, count) { db.setCount('pid:' + pid + ':users_favourited', function(err, count) {
posts.setPostField(pid, 'reputation', count); posts.setPostField(pid, 'favourited', count);
});
}); });
if (uid !== postData.uid) {
user.incrementUserFieldBy(postData.uid, 'reputation', 1, function (err, newreputation) {
db.sortedSetAdd('users:reputation', newreputation, postData.uid);
}); });
}
if (room_id) { if (room_id) {
websockets.in(room_id).emit('event:favourited', { websockets.in(room_id).emit('event:favourited', {
@ -211,21 +201,13 @@ var async = require('async'),
posts.getPostField(pid, 'uid', function (err, uid_of_poster) { posts.getPostField(pid, 'uid', function (err, uid_of_poster) {
Favourites.hasFavourited(pid, uid, function (err, hasFavourited) { Favourites.hasFavourited(pid, uid, function (err, hasFavourited) {
if (hasFavourited) { if (hasFavourited) {
db.sortedSetRemove('uid:' + uid + ':favourites', pid); db.sortedSetRemove('uid:' + uid + ':favourites', pid);
db.setRemove('pid:' + pid + ':users_favourited', uid, function(err) { db.setRemove('pid:' + pid + ':users_favourited', uid, function(err) {
db.setCount('pid:' + pid + ':users_favourited', function(err, count) { db.setCount('pid:' + pid + ':users_favourited', function(err, count) {
posts.setPostField(pid, 'reputation', count); posts.setPostField(pid, 'favourited', count);
}); });
}); });
if (uid !== uid_of_poster) {
user.incrementUserFieldBy(uid_of_poster, 'reputation', -1, function (err, newreputation) {
db.sortedSetAdd('users:reputation', newreputation, uid_of_poster);
});
}
if (room_id) { if (room_id) {
websockets.in(room_id).emit('event:unfavourited', { websockets.in(room_id).emit('event:unfavourited', {
uid: uid !== uid_of_poster ? uid_of_poster : 0, uid: uid !== uid_of_poster ? uid_of_poster : 0,

Loading…
Cancel
Save