Skip to content
Snippets Groups Projects
Commit 647312ae authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Replace all ChatSubscription.remove

parent 12ef1b45
No related branches found
No related tags found
No related merge requests found
......@@ -117,15 +117,22 @@ RocketChat.models.Subscriptions = new class asd extends RocketChat.models._Base
return @insert subscription
# # REMOVE
# removeById: (_id) ->
# return @remove _id
# removeByUnverifiedEmail: (email) ->
# query =
# emails:
# $elemMatch:
# address: email
# verified: false
# return @remove query
# REMOVE
removeByUserId: (userId) ->
query =
"u._id": userId
return @remove query
removeByRoomId: (roomId) ->
query =
rid: roomId
return @remove query
removeByRoomIdAndUserId: (roomId, userId) ->
query =
rid: roomId
"u._id": userId
return @remove query
......@@ -21,7 +21,7 @@ Meteor.methods
ChatSubscription.remove { "u._id": userId } # Remove user subscriptions
RocketChat.models.Subscriptions.removeByUserId userId # Remove user subscriptions
rooms = ChatRoom.find({ "u._id": userId }).fetch()
......
......@@ -10,7 +10,7 @@ Meteor.methods
# ChatRoom.update({ _id: rid}, {'$pull': { userWatching: Meteor.userId(), userIn: Meteor.userId() }})
ChatMessage.remove({rid: rid})
ChatSubscription.remove({rid: rid})
RocketChat.models.Subscriptions.removeByRoomId rid
ChatRoom.remove(rid)
# @TODO remove das mensagens lidas do usuário
else
......
......@@ -39,7 +39,7 @@ Meteor.methods
update.$set['u._id'] = newOwner._id
update.$set['u.username'] = newOwner.username
ChatSubscription.remove { rid: rid, 'u._id': Meteor.userId() }
RocketChat.models.Subscriptions.removeByRoomIdAndUserId rid, Meteor.userId()
ChatRoom.update rid, update
......
......@@ -16,7 +16,7 @@ Meteor.methods
ChatRoom.update data.rid, update
ChatSubscription.remove { 'u._id': data.username, rid: data.rid }
RocketChat.models.Subscriptions.removeByRoomIdAndUserId data.rid, data.username
switch room.t
when 'c'
......
......@@ -8,7 +8,7 @@ Meteor.startup ->
console.log 'Dropped: ', room.name
ChatRoom.remove room._id
ChatMessage.remove {rid: room._id}
ChatSubscription.remove {rid: room._id}
RocketChat.models.Subscriptions.removeByRoomId room._id
console.log 'Dropping test rooms with less than 2 user'
......@@ -16,7 +16,7 @@ Meteor.startup ->
console.log 'Dropped: ', room.name
ChatRoom.remove room._id
ChatMessage.remove {rid: room._id}
ChatSubscription.remove {rid: room._id}
RocketChat.models.Subscriptions.removeByRoomId room._id
console.log 'Adding username to all users'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment