|
|
|
@ -17,12 +17,71 @@ RocketChat.models.Messages = new class asd extends RocketChat.models._Base |
|
|
|
|
|
|
|
|
|
return @findOne query, options |
|
|
|
|
|
|
|
|
|
# # FIND |
|
|
|
|
# findByType: (type, options) -> |
|
|
|
|
# query = |
|
|
|
|
# t: type |
|
|
|
|
# FIND |
|
|
|
|
findByMention: (username, options) -> |
|
|
|
|
query = |
|
|
|
|
"mentions.username": username |
|
|
|
|
|
|
|
|
|
return @find query, options |
|
|
|
|
|
|
|
|
|
findVisibleByRoomId: (roomId, options) -> |
|
|
|
|
query = |
|
|
|
|
_hidden: |
|
|
|
|
$ne: true |
|
|
|
|
rid: roomId |
|
|
|
|
|
|
|
|
|
return @find query, options |
|
|
|
|
|
|
|
|
|
findInvisibleByRoomId: (roomId, options) -> |
|
|
|
|
query = |
|
|
|
|
_hidden: true |
|
|
|
|
rid: roomId |
|
|
|
|
|
|
|
|
|
return @find query, options |
|
|
|
|
|
|
|
|
|
# return @find query, options |
|
|
|
|
findVisibleByRoomIdAfterTimestamp: (roomId, timestamp, options) -> |
|
|
|
|
query = |
|
|
|
|
_hidden: |
|
|
|
|
$ne: true |
|
|
|
|
rid: roomId |
|
|
|
|
ts: |
|
|
|
|
$gt: timestamp |
|
|
|
|
|
|
|
|
|
return @find query, options |
|
|
|
|
|
|
|
|
|
findVisibleByRoomIdBeforeTimestamp: (roomId, timestamp, options) -> |
|
|
|
|
query = |
|
|
|
|
_hidden: |
|
|
|
|
$ne: true |
|
|
|
|
rid: roomId |
|
|
|
|
ts: |
|
|
|
|
$lt: timestamp |
|
|
|
|
|
|
|
|
|
return @find query, options |
|
|
|
|
|
|
|
|
|
findVisibleByRoomIdBetweenTimestamps: (roomId, afterTimestamp, beforeTimestamp, options) -> |
|
|
|
|
query = |
|
|
|
|
_hidden: |
|
|
|
|
$ne: true |
|
|
|
|
rid: roomId |
|
|
|
|
ts: |
|
|
|
|
$gt = afterTimestamp |
|
|
|
|
$lt = beforeTimestamp |
|
|
|
|
|
|
|
|
|
return @find query, options |
|
|
|
|
|
|
|
|
|
findVisibleCreatedOrEditedAfterTimestamp: (timestamp) -> |
|
|
|
|
query = |
|
|
|
|
_hidden: { $ne: true } |
|
|
|
|
$or: [ |
|
|
|
|
ts: |
|
|
|
|
$gt: timestamp |
|
|
|
|
, |
|
|
|
|
ets: |
|
|
|
|
$gt: timestamp |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
return @find query, options |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # UPDATE |
|
|
|
|