Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements/integrations #1625

Merged
merged 6 commits into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"Add_Members" : "Add Members",
"Add_users" : "Add users",
"Administration" : "Administration",
"Alias" : "Alias",
"All_channels" : "All channels",
"Allow_Invalid_SelfSigned_Certs" : "Allow Invalid Self-Signed Certs",
"Allow_Invalid_SelfSigned_Certs_Description" : "Allow invalid and self-signed SSL certificate's for link validation and previews.",
Expand All @@ -79,6 +80,7 @@
"Are_you_sure" : "Are you sure?",
"Auto_Load_Images" : "Auto Load Images",
"Avatar_changed_successfully" : "Avatar changed successfully",
"Avatar_URL" : "Avatar URL",
"Avatar_url_invalid_or_error" : "The url provided is invalid or not accessible. Please try again, but with a different url.",
"away" : "away",
"Away" : "Away",
Expand All @@ -102,6 +104,7 @@
"Channels" : "Channels",
"Channels_list" : "List of public channels",
"Chat_Rooms" : "Chat Rooms",
"Choose_the_alias_that_will_appear_before_the_username_in_messages" : "Choose the alias that will appear before the username in messages.",
"Choose_the_username_that_this_integration_will_post_as" : "Choose the username that this integration will post as.",
"Clear_all_unreads_question" : "Clear all unreads?",
"close" : "close",
Expand All @@ -118,6 +121,7 @@
"Create_new_private_group" : "Create a new private group",
"Create_new_public_channel" : "Create a new public channel",
"Created_at" : "Created at",
"Created_at_s_by_s" : "Created at <strong>%s</strong> by <strong>%s</strong>",
"Custom_oauth_helper" : "When setting up your OAuth Provider, you'll have to inform a Callback URL. Use <pre>%s</pre> .",
"Custom_oauth_unique_name" : "Custom oauth unique name",
"days" : "days",
Expand Down Expand Up @@ -153,8 +157,8 @@
"FileUpload" : "File Upload",
"FileUpload_Enabled" : "File Uploads Enabled",
"FileUpload_MaxFileSize" : "Maximum File Upload Size (in bytes)",
"FileUpload_MediaTypeWhiteList" : "Accepted Media Types",
"FileUpload_MediaType_NotAccepted" : "Media Types Not Accepted",
"FileUpload_MediaTypeWhiteList" : "Accepted Media Types",
"FileUpload_MediaTypeWhiteListDescription" : "Comma-separated list of media types",
"Follow_social_profiles" : "Follow our social profiles, fork us on github and share your thoughts about the rocket.chat app on our trello board.",
"Forgot_password" : "Forgot your password",
Expand Down Expand Up @@ -285,6 +289,7 @@
"Name" : "Name",
"Name_cant_be_empty" : "Name can't be empty",
"Name_optional" : "Name (optional)",
"New_integration" : "New integration",
"New_messages" : "New messages",
"New_password" : "New password",
"No_channel_with_name_%s_was_found" : "No channel with name <strong>\"%s\"</strong> was found!",
Expand Down Expand Up @@ -320,10 +325,8 @@
"Please_wait_activation" : "Please wait, this can take some time.",
"Please_wait_statistics" : "Please wait, statistics are being generated.",
"Post_as" : "Post as",
"New_integration" : "New integration",
"Post_to_s_as_s" : "Post to <strong>%s</strong> as <strong>%s</strong>",
"Created_at_s_by_s" : "Created at <strong>%s</strong> by <strong>%s</strong>",
"Post_to_Channel" : "Post to Channel",
"Post_to_s_as_s" : "Post to <strong>%s</strong> as <strong>%s</strong>",
"Powered_by" : "Powered by",
"Preferences" : "Preferences",
"Preferences_saved" : "Preferences saved",
Expand Down Expand Up @@ -402,6 +405,7 @@
"Send_your_JSON_payloads_to_this_URL" : "Send your JSON payloads to this URL.",
"Settings" : "Settings",
"Settings_updated" : "Settings updated",
"Should_be_a_URL_of_an_image" : "Should be a URL of an image.",
"Should_exists_a_user_with_this_username" : "Should exists a user with this username.",
"Showing_online_users" : "Showing <b>__total_online__</b> of __total__ users",
"Showing_results" : "<p>Showing <b>%s</b> results</p>",
Expand Down Expand Up @@ -481,6 +485,7 @@
"User_left_male" : "Has left the channel.",
"User_logged_out" : "User is logged out",
"User_not_found_or_incorrect_password" : "User not found or incorrect password",
"User_or_channel_name" : "User or channel name",
"User_removed_by" : "User <em>__user_removed__</em> removed by <em>__user_by__</em>.",
"User_Settings" : "User Settings",
"User_updated_successfully" : "User updated successfully",
Expand All @@ -505,6 +510,7 @@
"Yes_clear_all" : "Yes, clear all!",
"Yes_delete_it" : "Yes, delete it!",
"you_are_in_preview_mode_of" : "You are in preview mode of channel #<strong>__room_name__</strong>",
"You_can_change_a_different_avatar_too" : "You can change a different avatar too",
"You_need_confirm_email" : "You need to confirm your email to login!",
"You_should_name_it_to_easily_manage_your_integrations" : "You should name it to easily manage your integrations.",
"You_will_not_be_able_to_recover" : "You will not be able to recover this message!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@
border-bottom: none;
}
}

.message-example {
li {
list-style: none;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Template.integrationsIncoming.onCreated ->
@record = new ReactiveVar
username: 'rocket.cat'


Template.integrationsIncoming.helpers

hasPermission: ->
Expand All @@ -10,12 +15,42 @@ Template.integrationsIncoming.helpers
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 {}
return Template.instance().record.curValue

example: ->
record = Template.instance().record.get()
return {} =
_id: Random.id()
alias: record.alias
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


Template.integrationsIncoming.events
"blur input": (e, t) ->
t.record.set
name: $('[name=name]').val().trim()
alias: $('[name=alias]').val().trim()
avatar: $('[name=avatar]').val().trim()
channel: $('[name=channel]').val().trim()
username: $('[name=username]').val().trim()

"click .submit > .delete": ->
params = Template.instance().data.params()

Expand All @@ -42,6 +77,8 @@ Template.integrationsIncoming.events

"click .submit > .save": ->
name = $('[name=name]').val().trim()
alias = $('[name=alias]').val().trim()
avatar = $('[name=avatar]').val().trim()
channel = $('[name=channel]').val().trim()
username = $('[name=username]').val().trim()

Expand All @@ -53,6 +90,8 @@ Template.integrationsIncoming.events

integration =
channel: channel
alias: alias if alias isnt ''
avatar: avatar if avatar isnt ''
name: name if name isnt ''

params = Template.instance().data.params?()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="input-line double-col">
<label>{{_ "Post_as"}}</label>
<div>
{{#if data.username}}
{{#if data.token}}
<input type="text" name="username" value="{{data.username}}" disabled="disabled" />
{{else}}
<input type="text" name="username" value="{{data.username}}" />
Expand All @@ -32,6 +32,21 @@
<div class="settings-description">{{_ "Should_exists_a_user_with_this_username"}}</div>
</div>
</div>
<div class="input-line double-col">
<label>{{_ "Alias"}} ({{_ "optional"}})</label>
<div>
<input type="text" name="alias" value="{{data.alias}}" placeholder="{{_ 'Optional'}}" />
<div class="settings-description">{{_ "Choose_the_alias_that_will_appear_before_the_username_in_messages"}}</div>
</div>
</div>
<div class="input-line double-col">
<label>{{_ "Avatar_URL"}} ({{_ "optional"}})</label>
<div>
<input type="url" name="avatar" value="{{data.avatar}}" placeholder="{{_ 'Optional'}}" />
<div class="settings-description">{{_ "You_can_change_a_different_avatar_too"}}</div>
<div class="settings-description">{{_ "Should_be_a_URL_of_an_image"}}</div>
</div>
</div>
{{#if data.token}}
<div class="input-line double-col">
<label>Webhook URL</label>
Expand All @@ -42,6 +57,9 @@
</div>
</div>
{{/if}}
<div class="input-line message-example">
{{#nrr nrrargs 'message' example}}{{/nrr}}
</div>
</div>
</div>
<div class="submit">
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-integrations/server/api/api.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ Api.addRoute ':integrationId/:userId/:token', authRequired: true,
error: 'invalid-channel-type'

message =
avatar: integration.avatar
alias: integration.alias
msg: @bodyParams.text or ''
attachments: @bodyParams.attachments
parseUrls: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Meteor.methods
RocketChat.models.Integrations.update integrationId,
$set:
name: integration.name
avatar: integration.avatar
alias: integration.alias
channel: integration.channel
_updatedAt: new Date
_updatedBy: RocketChat.models.Users.findOne @userId, {fields: {username: 1}}
Expand Down
7 changes: 7 additions & 0 deletions packages/rocketchat-theme/assets/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ select,
input[type='text'],
input[type='number'],
input[type='email'],
input[type='url'],
input[type='password'] {
-webkit-appearance: none;
height: 35px;
Expand Down Expand Up @@ -466,6 +467,7 @@ form.inline {
input[type='text'],
input[type='number'],
input[type='email'],
input[type='url'],
input[type='password'] {
width: auto;
}
Expand Down Expand Up @@ -2700,6 +2702,11 @@ a.github-fork {
&.temp .body {
opacity: .5;
}
.message-alias {
color: #aaa;
font-weight: 400;
padding-left: 2px;
}
}

.compact {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ select,
input[type='text'],
input[type='number'],
input[type='email'],
input[type='url'],
input[type='password'] {
border-color: #E7E7E7;
background-color: #fff;
Expand Down
16 changes: 14 additions & 2 deletions packages/rocketchat-ui-message/message/message.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
<template name="message">
<li id="{{_id}}" class="message sequential {{system}} {{t}} {{own}} {{isTemp}} {{chatops}}" data-username="{{u.username}}" data-bot="{{isBot}}" data-date="{{date}}">
<a class="thumb user-card-message" href="#" data-username="{{u.username}}" tabindex="1">{{> avatar username=u.username}}</a>
<a class="user user-card-message" href="#" data-username="{{u.username}}" tabindex="1">{{u.username}}</a>
{{#if avatar}}
<a class="thumb user-card-message" href="#" data-username="{{u.username}}" tabindex="1">
<div class="avatar">
<div class="avatar-image" style="background-image:url({{avatar}});"></div>
</div>
</a>
{{else}}
<a class="thumb user-card-message" href="#" data-username="{{u.username}}" tabindex="1">{{> avatar username=u.username}}</a>
{{/if}}
{{#if alias}}
<a class="user user-card-message" href="#" data-username="{{u.username}}" tabindex="1">{{alias}} <span class="message-alias">@{{u.username}}</span></a>
{{else}}
<a class="user user-card-message" href="#" data-username="{{u.username}}" tabindex="1">{{u.username}}</a>
{{/if}}
<span class="info">
{{#if isBot}}
<span class="is-bot">BOT</span>
Expand Down
Binary file added private/avatars/rocketcat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions server/startup/initialData.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ Meteor.startup ->
RocketChat.models.Rooms.createWithIdTypeAndName 'GENERAL', 'c', 'general',
default: true

if not RocketChat.models.Users.findOneById('rocket.cat')?
RocketChat.models.Users.create
_id: 'rocket.cat'
name: "Rocket.Cat"
username: 'rocket.cat'
status: "offline"
statusDefault: "offline"
utcOffset: 0
active: true
bot: true

rs = RocketChatFile.bufferToStream new Buffer(Assets.getBinary('avatars/rocketcat.png'), 'utf8')
RocketChatFileAvatarInstance.deleteFile "rocket.cat.jpg"
ws = RocketChatFileAvatarInstance.createWriteStream "rocket.cat.jpg", 'image/png'
ws.on 'end', Meteor.bindEnvironment ->
RocketChat.models.Users.setAvatarOrigin 'rocket.cat', 'local'

rs.pipe(ws)


if process.env.ADMIN_EMAIL? and process.env.ADMIN_PASS?
re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if re.test process.env.ADMIN_EMAIL
Expand Down