-
Rodrigo Nascimento authoredRodrigo Nascimento authored
integrationsIncoming.coffee 4.22 KiB
Template.integrationsIncoming.onCreated ->
@record = new ReactiveVar
username: 'rocket.cat'
Template.integrationsIncoming.helpers
hasPermission: ->
return RocketChat.authz.hasAllPermission 'manage-integrations'
data: ->
params = Template.instance().data.params?()
if params?.id?
data = ChatIntegrations.findOne({_id: params.id})
if data?
data.url = Meteor.absoluteUrl("hooks/#{encodeURIComponent(data._id)}/#{encodeURIComponent(data.userId)}/#{encodeURIComponent(data.token)}")
Template.instance().record.set data
return data
return Template.instance().record.curValue
example: ->
record = Template.instance().record.get()
return {} =
_id: Random.id()
alias: record.alias
emoji: record.emoji
avatar: record.avatar
msg: 'Example message'
bot:
i: Random.id()
attachments: [{
title: "Rocket.Chat"
title_link: "https://rocket.chat"
text: "Rocket.Chat, the best open source chat"
image_url: "https://rocket.chat/images/mockup.png"
color: "#764FA5"
}]
ts: new Date
u:
_id: Random.id()
username: record.username
exampleJson: ->
record = Template.instance().record.get()
data =
username: record.alias
icon_emoji: record.emoji
icon_url: record.avatar
text: 'Example message'
attachments: [{
title: "Rocket.Chat"
title_link: "https://rocket.chat"
text: "Rocket.Chat, the best open source chat"
image_url: "https://rocket.chat/images/mockup.png"
color: "#764FA5"
}]
for key, value of data
delete data[key] if value in [null, ""]
return hljs.highlight('json', JSON.stringify(data, null, 2)).value
curl: ->
record = Template.instance().record.get()
data =
username: record.alias
icon_emoji: record.emoji
icon_url: record.avatar