-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmailbox.js
More file actions
116 lines (98 loc) · 3.09 KB
/
mailbox.js
File metadata and controls
116 lines (98 loc) · 3.09 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// CLIENT SIDE
if (Meteor.isClient) {
Template.mailbox.helpers({
getBorrowingMailInfos: function() {
var currentUserId = Meteor.userId();
// var mailInfos = [];
// MAILBOX.find({sender_Id: currentUserId}).forEach(function(element) {mailInfos.push(element);});;
// console.log(mailInfos);
return MAILBOX.find({sender_Id: currentUserId});
},
getLendingMailInfos: function() {
var currentUserId = Meteor.userId();
// var mailInfos = [];
// MAILBOX.find({sender_Id: currentUserId}).forEach(function(element) {mailInfos.push(element);});;
// console.log(mailInfos);
return MAILBOX.find({recipient_Id: currentUserId});
},
getSenderPhoto: function() {
var sender_Id = this.sender_Id;
var sender = Meteor.users.findOne({_id:sender_Id});
var senderProfilePic = sender && sender.profile && sender.profile.pic;
return IMAGES.findOne({_id:senderProfilePic});
},
getRecipientPhoto: function() {
var recipient_Id = this.recipient_Id;
var recipient = Meteor.users.findOne({_id:recipient_Id});
var recipientProfilePic = recipient && recipient.profile && recipient.profile.pic;
return IMAGES.findOne({_id:recipientProfilePic});
},
getSenderName: function() {
var sender_Id = this.sender_Id;
var sender = Meteor.users.findOne({_id:sender_Id});
var senderName = sender && sender.profile && sender.profile.firstName;
return senderName;
},
getRecipientName: function() {
var recipient_Id = this.recipient_Id;
var recipient = Meteor.users.findOne({_id:recipient_Id});
var recipientName = recipient && recipient.profile && recipient.profile.firstName;
return recipientName;
},
getBookTitle: function() {
var book_Id = this.book_Id;
var book = BOOKS_INFOS.findOne({_id:book_Id});
var bookTitle = book && book.title;
return bookTitle;
},
getBookThumb: function() {
var book_Id = this.book_Id;
var book = BOOKS_INFOS.findOne({_id:book_Id});
var thumb = book && book.thumb;
if (thumb) {
return BOOKS_INFOS.findOne({_id:book_Id}).thumb;
}
},
getLastDiscussionDate: function() {
var lastDiscussionDate = this.lastDisussionDate;
var momentLastDiscussionDate = moment.utc(lastDiscussionDate).format('MMMM Do YYYY');
var c = moment(momentLastDiscussionDate).fromNow();
return c;
},
getCreatedAt: function() {
var createdAt = this.createdAt;
var createdAt = moment.utc(createdAt).format('MMMM Do YYYY');
return createdAt;
},
getReadBySender: function() {
var readBySender = this.readBySender;
return readBySender;
},
getReadByRecipient: function() {
var readByRecipient = this.readByRecipient;
return readByRecipient;
},
isStatusWaiting: function() {
var status = this.status;
if (status === "waiting"){return true;}
else {return false;}
},
isStatusRefused: function() {
var status = this.status;
if (status === "refused"){return true;}
else {return false;}
},
isStatusAccepted: function() {
var status = this.status;
if (status === "accepted"){return true;}
else {return false;}
},
getConversationId:function() {
var Id = this._id;
return Id;
}
});
}
// CLIENT SIDE
if (Meteor.isServer) {
}