editing of posts

This commit is contained in:
Julian Lam
2013-05-09 10:20:25 -04:00
parent f218e0f3a7
commit e9a552eab4
6 changed files with 89 additions and 16 deletions

View File

@@ -68,13 +68,11 @@ var RDB = require('./redis.js'),
pid.push(pids[i]);
}
Posts.getFavouritesByPostIDs(pids, current_user, function(fav_data) {
vote_data = fav_data;
generateThread();
});
RDB.multi()
.mget(content)
.mget(uid)
@@ -182,6 +180,7 @@ var RDB = require('./redis.js'),
RDB.set('pid:' + pid + ':uid', uid);
RDB.set('pid:' + pid + ':timestamp', new Date().getTime());
RDB.set('pid:' + pid + ':rep', 0);
RDB.set('pid:' + pid + ':tid', tid);
RDB.incr('tid:' + tid + ':postcount');
@@ -189,7 +188,7 @@ var RDB = require('./redis.js'),
RDB.lpush('uid:' + uid + ':posts', pid);
user.incrementUserFieldBy(uid, 'postcount', 1);
if (callback)
callback(pid);
});
@@ -262,4 +261,17 @@ var RDB = require('./redis.js'),
}(pids[i]))
}
}
Posts.getRawContent = function(pid, socket) {
RDB.get('pid:' + pid + ':content', function(err, raw) {
socket.emit('api:posts.getRawPost', { post: raw });
});
}
Posts.edit = function(pid, content) {
RDB.get('pid:' + pid + ':tid', function(err, tid) {
RDB.set('pid:' + pid + ':content', content);
io.sockets.in('topic_' + tid).emit('event:post_edited', { pid: pid, content: marked(content || '') });
});
}
}(exports));