-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from RocketChat/subscription-manager
Subscription manager and meny other improovments
- Loading branch information
Showing
56 changed files
with
912 additions
and
1,980 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Meteor.methods | ||
hideRoom: (rid) -> | ||
if not Meteor.userId() | ||
throw new Meteor.Error 203, t('general.User_logged_out') | ||
|
||
ChatSubscription.update | ||
rid: rid | ||
, | ||
$set: | ||
alert: false | ||
open: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
Meteor.methods | ||
leaveRoom: (roomId) -> | ||
room = ChatRoom.findOne roomId | ||
leaveRoom: (rid) -> | ||
if not Meteor.userId() | ||
throw new Meteor.Error 203, t('general.User_logged_out') | ||
|
||
update = | ||
ChatSubscription.remove | ||
rid: rid | ||
'u._id': Meteor.userId() | ||
|
||
ChatRoom.update rid, | ||
$pull: | ||
usernames: Meteor.user().username | ||
|
||
ChatSubscription.remove { rid: roomId, 'u._id': Meteor.userId() } | ||
|
||
ChatRoom.update roomId, update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Meteor.methods | ||
saveRoomName: (rid, name) -> | ||
if not Meteor.userId() | ||
throw new Meteor.Error 203, t('general.User_logged_out') | ||
|
||
room = ChatRoom.findOne rid | ||
|
||
if room.u._id isnt Meteor.userId() or room.t not in ['c', 'p'] | ||
throw new Meteor.Error 403, 'Not allowed' | ||
|
||
name = _.slugify name | ||
|
||
if name is room.name | ||
return | ||
|
||
ChatRoom.update rid, | ||
$set: | ||
name: name | ||
|
||
ChatSubscription.update | ||
rid: rid | ||
, | ||
$set: | ||
name: name | ||
|
||
return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
Meteor.methods | ||
sendMessage: (msg) -> | ||
sendMessage: (message) -> | ||
if not Meteor.userId() | ||
throw new Meteor.Error 203, t('general.User_logged_out') | ||
|
||
Tracker.nonreactive -> | ||
now = new Date(Date.now() + TimeSync.serverOffset()) | ||
|
||
msg = RocketChat.callbacks.run 'sendMessage', msg | ||
message.ts = new Date(Date.now() + TimeSync.serverOffset()) | ||
message.u = | ||
_id: Meteor.userId() | ||
username: Meteor.user().username | ||
message = RocketChat.callbacks.run 'beforeSaveMessage', message | ||
|
||
ChatMessage.upsert { rid: msg.rid, t: 't' }, | ||
$set: | ||
ts: now | ||
msg: msg.message | ||
'u.username': Meteor.user().username | ||
ChatMessage.upsert | ||
rid: message.rid | ||
t: 't' | ||
, | ||
$set: message | ||
$unset: | ||
t: 1 | ||
expireAt: 1 | ||
|
||
updateMessage: (msg) -> | ||
Tracker.nonreactive -> | ||
now = new Date(Date.now() + TimeSync.serverOffset()) | ||
|
||
ChatMessage.update { _id: msg.id, 'u._id': Meteor.userId() }, | ||
$set: | ||
ets: now | ||
msg: msg.message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Meteor.methods | ||
toogleFavorite: (rid, f) -> | ||
if not Meteor.userId() | ||
throw new Meteor.Error 203, t('general.User_logged_out') | ||
|
||
ChatSubscription.update | ||
rid: rid | ||
'u._id': Meteor.userId() | ||
, | ||
$set: | ||
f: f |
Oops, something went wrong.