parent
f038986121
commit
97693ff147
@ -1,2 +1 @@ |
||||
this.SnippetedMessage = new Meteor.Collection('rocketchat_snippeted_message'); |
||||
this.Messages = new Meteor.Collection('rocketchat_message'); |
||||
|
||||
@ -1,27 +0,0 @@ |
||||
class SnippetMessage extends RocketChat.models._Base { |
||||
constructor() { |
||||
super('snippeted_message'); |
||||
|
||||
this.tryEnsureIndex({ 'name': 1 }); |
||||
this.tryEnsureIndex({ 'extension': 1}); |
||||
} |
||||
|
||||
findOneById(_id, options) { |
||||
return this.findOne(_id, options); |
||||
} |
||||
|
||||
findByRoomId(rid, options) { |
||||
return this.find({rid: rid}, options); |
||||
} |
||||
|
||||
setFileName(_id, name) { |
||||
let update = { |
||||
$set: { |
||||
filename: name |
||||
} |
||||
}; |
||||
return this.update({_id}, update); |
||||
} |
||||
} |
||||
|
||||
RocketChat.models.SnippetMessage = new SnippetMessage(); |
||||
@ -1,37 +0,0 @@ |
||||
Meteor.publish('retrieveSnippetMessage', function(snippetId) { |
||||
let messageSnippetedCollection = 'rocketchat_snippeted_message'; |
||||
|
||||
if (typeof this.userId === 'undefined' || this.userId === null) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
let publication = this; |
||||
|
||||
let user = RocketChat.models.Users.findOneById(this.userId); |
||||
|
||||
if (typeof user === 'undefined' || user === null) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
let cursor = RocketChat.models.SnippetMessage.find( |
||||
{ |
||||
_id: snippetId |
||||
} |
||||
).observeChanges({ |
||||
added: function(_id, record) { |
||||
publication.added(messageSnippetedCollection, _id, record); |
||||
}, |
||||
changed: function(_id, record) { |
||||
publication.changed(messageSnippetedCollection, _id, record); |
||||
}, |
||||
removed: function(_id) { |
||||
publication.removed(messageSnippetedCollection, _id); |
||||
} |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop = function() { |
||||
cursor.stop(); |
||||
}; |
||||
}); |
||||
Loading…
Reference in new issue