-
Notifications
You must be signed in to change notification settings - Fork 1
/
library.js
54 lines (47 loc) · 988 Bytes
/
library.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(function (module) {
"use strict";
var highlights = {};
var opUID;
var postCount = true;
var topics = require.main.require('./src/topics'),
user = require.main.require('./src/user'),
async = require('async');
/**
* Parsea todos los posts del hilo en busca de los mensajes del OP
*/
highlights.parse = function (data, callback) {
async.eachSeries(data.posts,
function(p, cb){
if (p && data.uid)
{
topics.getTopicData(p.tid, function (err, topic) {
if (err || !topic) {
p.isOP = false;
p.isFollow = false;
cb();
}
opUID = topic.uid;
p.isOP = false;
if ( opUID == p.uid ) {
p.isOP = true;
}
user.isFollowing(data.uid, p.uid, function (err, isfow) {
if (err) {
cb();
}
p.isFollow = isfow;
//console.log(p);
cb();
});
});
}
else
{
cb();
}
}, function(r){
callback(null, data);
});
};
module.exports = highlights;
}(module));