Skip to content

Node.js based forum software built for the modern web

get pid and tid and cid methods in posts and topics

Julian Lame5716145ae94
diff --git a/src/posts.js b/src/posts.js
index 0bcaa763ac..6a3d49db03 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -181,6 +181,25 @@ marked.setOptions({
}
}
+ Posts.editable = function(uid, pid) {
+
+ }
+
+ Posts.get_tid_by_pid = function(pid, callback) {
+ RDB.get('pid:' + pid + ':tid', function(err, tid) {
+ if (tid && parseInt(tid) > 0) callback(tid);
+ else callback(false);
+ });
+ }
+
+ Posts.get_cid_by_pid = function(pid, callback) {
+ Posts.get_tid(pid, function(tid) {
+ if (tid) topics.get_cid_by_tid(tid, function(cid) {
+ if (cid) callback(cid);
+ else callback(false);
+ });
+ })
+ }
Posts.reply = function(socket, tid, uid, content) {
if (uid < 1) {
diff --git a/src/topics.js b/src/topics.js
index a10e9e64d4..6929760f0a 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -166,6 +166,12 @@ var RDB = require('./redis.js'),
});
}
+ Topics.get_cid_by_tid = function(tid, callback) {
+ RDB.get('tid:' + pid + ':cid', function(err, cid) {
+ if (cid && parseInt(cid) > 0) callback(cid);
+ else callback(false);
+ });
+ }
Topics.markAsRead = function(tid, uid) {
RDB.sadd('tid:' + tid + ':read_by_uid', uid);