The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/packages/rocketchat-message-snippet/client/page/snippetPage.js

47 lines
1.3 KiB

Template.snippetPage.helpers({
snippet: function() {
return SnippetedMessage.findOne({ _id: FlowRouter.getParam("snippetId") });
},
snippetContent: function() {
let message = Messages.findOne({snippetId: FlowRouter.getParam("snippetId")});
if (message == undefined) {
return null
} else {
message.html = message.msg;
return RocketChat.MarkdownCode(message).tokens[0].text;
}
},
own() {
let snippet = SnippetedMessage.findOne({ _id: FlowRouter.getParam("snippetId") });
if (snippet !== undefined &&
snippet.u !== undefined &&
snippet.u._id === Meteor.userId()) {
return 'own'
}
return null;
},
date() {
let snippet = SnippetedMessage.findOne({ _id: FlowRouter.getParam("snippetId") });
if (snippet !== undefined) {
console.log(snippet.ts);
return moment(snippet.ts).format(RocketChat.settings.get('Message_DateFormat'))
}
},
time() {
let snippet = SnippetedMessage.findOne({ _id: FlowRouter.getParam("snippetId") });
if (snippet !== undefined) {
return moment(snippet.ts).format(RocketChat.settings.get('Message_TimeFormat'))
}
}
});
Template.snippetPage.onCreated(function() {
this.autorun(function() {
let snippetId = FlowRouter.getParam("snippetId");
Meteor.subscribe("retrieveSnippetedMessage", snippetId);
Meteor.subscribe("retrieveSnippetMessage", snippetId);
});
});