diff --git a/client/lib/chatMessages.coffee b/client/lib/chatMessages.coffee index 4113b2f2e3dbd69f9f638ad0ca57e7f3973386a3..1e158c746dfd74da364e73cabfca2395c4981796 100644 --- a/client/lib/chatMessages.coffee +++ b/client/lib/chatMessages.coffee @@ -40,6 +40,7 @@ class @ChatMessages return -1 edit: (element, index) -> + return unless RocketChat.settings.get 'Message_AllowEditing' return if element.classList.contains("system") this.clearEditing() id = element.getAttribute("id") @@ -94,7 +95,7 @@ class @ChatMessages update: (id, rid, input) -> if _.trim(input.value) isnt '' msg = input.value - Meteor.call 'updateMessage', { id: id, msg: msg } + Meteor.call 'updateMessage', { _id: id, msg: msg, rid: rid } this.clearEditing() this.stopTyping(rid) diff --git a/client/methods/updateMessage.coffee b/client/methods/updateMessage.coffee index 688b23d9593bf757ec3933ac0453a5e9f9ee6a8c..0aef6afd0b223cf923b16ae4b00e7c77cc6d2cbd 100644 --- a/client/methods/updateMessage.coffee +++ b/client/methods/updateMessage.coffee @@ -14,4 +14,4 @@ Meteor.methods , $set: ets: message.ets - msg: message.msg \ No newline at end of file + msg: message.msg diff --git a/client/stylesheets/base.less b/client/stylesheets/base.less index 9454605b044e062b78b4731177b5942b71925d74..7eb77c254ea0905a1b1ff6de6746d19dc349fe7c 100644 --- a/client/stylesheets/base.less +++ b/client/stylesheets/base.less @@ -2191,14 +2191,14 @@ a.github-fork { display: none; cursor: pointer; } - &.own:hover .edit-message { + &.own:hover:not(.system) .edit-message { display: inline-block; } .delete-message { display: none; cursor: pointer; } - &.own:hover .delete-message { + &.own:hover:not(.system) .delete-message { display: inline-block; } .user { diff --git a/client/views/app/message.coffee b/client/views/app/message.coffee index 3e369c23dae3178697d4116f38c59a28ec5f813f..669387a6ba066be75336559b2a2e60c5653f362d 100644 --- a/client/views/app/message.coffee +++ b/client/views/app/message.coffee @@ -1,7 +1,7 @@ Template.message.helpers own: -> - return 'own' if this.u?._id is Meteor.userId() + return 'own' if this.u?._id is Meteor.userId() time: -> return moment(this.ts).format('HH:mm') @@ -23,6 +23,7 @@ Template.message.helpers when 'nu' then t('User_added', { user_added: this.u.username }) when 'uj' then t('User_joined_channel', { user: this.u.username }) when 'wm' then t('Welcome', { user: this.u.username }) + when 'rm' then t('Message_removed', { user: this.u.username }) when 'rtc' then RocketChat.callbacks.run 'renderRtcMessage', this else this.html = this.msg @@ -33,8 +34,15 @@ Template.message.helpers return this.html system: -> - return 'system' if this.t in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm', 'uj'] - + return 'system' if this.t in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm', 'uj', 'rm'] + edited: -> + return @ets and @t not in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm', 'uj', 'rm'] + canEdit: -> + return RocketChat.settings.get 'Message_AllowEditing' + canDelete: -> + return RocketChat.settings.get 'Message_AllowDeleting' + showEditedStatus: -> + return RocketChat.settings.get 'Message_ShowEditedStatus' Template.message.onViewRendered = (context) -> view = this diff --git a/client/views/app/message.html b/client/views/app/message.html index 3fdbf560cb9bde37fee165d5132c2d9d42e390e3..a43ed499ac8dab2cbda1bf4d2cb3bd27bc101ac0 100644 --- a/client/views/app/message.html +++ b/client/views/app/message.html @@ -4,11 +4,15 @@ <a class="user user-card-message" href="#" data-username="{{u.username}}" tabindex="1">{{u.username}}</a> <span class="info"> <span class="time">{{time}}</span> - {{#if ets}} + {{#if edited}} <span class="edited">({{_ "edited"}})</span> {{/if}} + {{#if canEdit}} <i class="icon-pencil edit-message"></i> + {{/if}} + {{#if canDelete}} <i class="icon-trash-1 delete-message"></i> + {{/if}} </span> <div class="body" dir="auto"> {{{body}}} diff --git a/client/views/main.coffee b/client/views/main.coffee index 5e10f432d134382d2341d0cd2f9551785eba2588..30f87a3fda7449b74aae00ec19ef2a7464f85264 100644 --- a/client/views/main.coffee +++ b/client/views/main.coffee @@ -19,48 +19,53 @@ Template.body.onRendered -> f.parentNode.insertBefore j, f Tracker.autorun (c) -> - if RocketChat.settings.get 'Meta:language' + if RocketChat.settings.get 'Meta_language' c.stop() + Meta.set name: 'http-equiv' property: 'content-language' - content: RocketChat.settings.get 'Meta:language' + content: RocketChat.settings.get 'Meta_language' Meta.set name: 'name' property: 'language' - content: RocketChat.settings.get 'Meta:language' + content: RocketChat.settings.get 'Meta_language' Tracker.autorun (c) -> - if RocketChat.settings.get 'Meta:fb:app_id' + if RocketChat.settings.get 'Meta_fb_app_id' c.stop() + Meta.set name: 'property' property: 'fb:app_id' - content: RocketChat.settings.get 'Meta:fb:app_id' + content: RocketChat.settings.get 'Meta_fb_app_id' Tracker.autorun (c) -> - if RocketChat.settings.get 'Meta:robots' + if RocketChat.settings.get 'Meta_robots' c.stop() + Meta.set name: 'name' property: 'robots' - content: RocketChat.settings.get 'Meta:robots' + content: RocketChat.settings.get 'Meta_robots' Tracker.autorun (c) -> - if RocketChat.settings.get 'Meta:google-site-verification' + if RocketChat.settings.get 'Meta_google-site-verification' c.stop() + Meta.set name: 'name' property: 'google-site-verification' - content: RocketChat.settings.get 'Meta:google-site-verification' + content: RocketChat.settings.get 'Meta_google-site-verification' Tracker.autorun (c) -> - if RocketChat.settings.get 'Meta:msvalidate.01' + if RocketChat.settings.get 'Meta_msvalidate01' c.stop() + Meta.set name: 'name' property: 'msvalidate.01' - content: RocketChat.settings.get 'Meta:msvalidate.01' + content: RocketChat.settings.get 'Meta_msvalidate01' if Meteor.isCordova $(document.body).addClass 'is-cordova' diff --git a/client/views/settings/settings.coffee b/client/views/settings/settings.coffee index 5c94f76c2d641dadaa7d8106c0fdc382ffa1ff2c..c89690ab609e581004f47ef43a39e7bc456e141b 100644 --- a/client/views/settings/settings.coffee +++ b/client/views/settings/settings.coffee @@ -42,8 +42,8 @@ Template.settings.events if not _.isEmpty updateSettings RocketChat.settings.batchSet updateSettings, (err, success) -> - return toastr.error TAPi18next.t 'Error_updating_settings' if err - toastr.success TAPi18next.t 'Settings_updated' + return toastr.error TAPi18next.t 'project:Error_updating_settings' if err + toastr.success TAPi18next.t 'project:Settings_updated' Template.settings.onRendered -> Tracker.afterFlush -> diff --git a/i18n/de.i18n.json b/i18n/de.i18n.json index 779bdb3a1f25eb589e63ff2dfe77e23b37de597c..e54feaf03578300d3da68542d0ddb12444b000e7 100644 --- a/i18n/de.i18n.json +++ b/i18n/de.i18n.json @@ -98,8 +98,8 @@ "Members_List" : "Mitgliederliste", "Members_placeholder" : "Mitglieder", "Message" : "Nachricht", - "Message_Edit" : "Erlaube Bearbeitung von Nachrichten", - "Message_Delete" : "Erlaube Nachrichten zu löschen", + "Message_AllowEditing" : "Erlaube Bearbeitung von Nachrichten", + "Message_AllowDeleting" : "Erlaube Nachrichten zu löschen", "Message_ShowEditedStatus" : "Zeige Bearbeitungsstatus", "Message_ShowDeletedStatus" : "Zeige Löschstatus", "Meta_language" : "Sprache", @@ -175,7 +175,6 @@ "SMTP_Host" : "SMTP Host", "SMTP_Password" : "SMTP Passwort", "SMTP_Port" : "SMTP Port", - "SMTP_Security" : "SMTP Sicherheit", "SMTP_Username" : "SMTP Benutzername", "Start_of_conversation" : "Beginn der Konversation", "strike" : "durchgestrichen", diff --git a/i18n/el.i18n.json b/i18n/el.i18n.json index 481ede59005f140c13261badc72563a32ced5b87..abff0d753918280b7d77049c8c444221666c19f2 100644 --- a/i18n/el.i18n.json +++ b/i18n/el.i18n.json @@ -98,11 +98,11 @@ "Members_List" : "Λίστα μελών", "Members_placeholder" : "ÎœÎλη", "Message" : "Μήνυμα", - "Message_Edit" : "ΕπιτÏÎπεται επεξεÏγασία μηνυμάτων", - "Message_Delete" : "ΕπιτÏÎπεται διαγÏαφή μηνυμάτων", + "Message_AllowEditing" : "ΕπιτÏÎπεται επεξεÏγασία μηνυμάτων", + "Message_AllowDeleting" : "ΕπιτÏÎπεται διαγÏαφή μηνυμάτων", "Message_ShowEditedStatus" : "Εμφάνιση ΕπεξεÏγασμÎνης Κατάστασης", "Message_ShowDeletedStatus" : "Εμφάνιση ΔιαγÏαμμÎνης Κατάστασης", - "Message_KeepStatusHistory" : "ΚÏατήστε ιστοÏικό κατάστασης", + "Message_KeepHistory" : "ΚÏατήστε ιστοÏικό κατάστασης", "Meta_language" : "Γλώσσα", "Meta_fb_app_id" : "Facebook APP ID", "Meta_robots" : "Ρομπότ", @@ -176,7 +176,6 @@ "SMTP_Host" : "SMTP Host", "SMTP_Password" : "SMTP Κωδικός", "SMTP_Port" : "SMTP ΘÏÏα", - "SMTP_Security" : "SMTP Ασφάλεια", "SMTP_Username" : "SMTP Όνομα χÏήστη", "Start_of_conversation" : "ΑÏχή της συνομιλίας", "strike" : "σβήσιμο", diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index ce8c14e38460ab03c0a484e78be1922b3631dcad..d86fd2036d60b4b0e82d889066645fd8353879ba 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -6,28 +6,28 @@ "Add_Members" : "Add Members", "Add_users" : "Add users", "All_channels" : "All channels", + "and" : "and", "API_Analytics" : "Analytics", "API_Embed" : "Embed", "App_Settings" : "App Settings", - "Avatar_changed_successfully" : "Avatar changed successfully", - "and" : "and", "are_also_typing" : "are also typing", "are_typing" : "are typing", "Are_you_sure" : "Are you sure?", + "Avatar_changed_successfully" : "Avatar changed successfully", "away" : "away", - "away_male" : "away", - "away_female" : "away", "Away" : "Away", - "Away_male" : "Away", + "away_female" : "away", "Away_female" : "Away", + "away_male" : "away", + "Away_male" : "Away", + "Back_to_login" : "Back to login", + "bold" : "bold", "busy" : "busy", - "busy_male" : "busy", - "busy_female" : "busy", "Busy" : "Busy", - "Busy_male" : "Busy", + "busy_female" : "busy", "Busy_female" : "Busy", - "Back_to_login" : "Back to login", - "bold" : "bold", + "busy_male" : "busy", + "Busy_male" : "Busy", "Cancel" : "Cancel", "Change_avatar" : "Change avatar", "Channels" : "Channels", @@ -40,18 +40,18 @@ "Conversation" : "Conversation", "Create_new" : "Create new", "Create_new_direct_message_room" : "Create a new direct message room", - "Create_new_public_channel" : "Create a new public channel", "Create_new_private_group" : "Create a new private group", + "Create_new_public_channel" : "Create a new public channel", "Created_at" : "Created at", - "Direct_Messages" : "Direct Messages", "Deleted" : "Deleted!", + "Direct_Messages" : "Direct Messages", "Drop_to_upload_file" : "Drop to upload file", - "Duplicate_private_group_name" : "A Private Group with name '%s' exists", "Duplicate_channel_name" : "A Channel with name '%s' exists", + "Duplicate_private_group_name" : "A Private Group with name '%s' exists", "edited" : "edited", + "Email_already_exists" : "Email already exists", "Email_or_username" : "Email or username", "Email_verified" : "Email verified", - "Email_already_exists" : "Email already exists", "Enter_info" : "Enter your information", "Error_changing_password" : "Password changed", "False" : "False", @@ -59,8 +59,8 @@ "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", "Fork_it_on_github" : "Fork it on github", - "github_no_public_email" : "You don't have any email as public email in your GitHub account", "Get_to_know_the_team" : "Get to know the Rocket.Team", + "github_no_public_email" : "You don't have any email as public email in your GitHub account", "Have_your_own_chat" : "Have your own web chat. Developed with Meteor.com, the Rocket.Chat is a great solution for developers looking forward to build and evolve their own chat platform.", "Hide_room" : "Hide room", "History" : "History", @@ -73,18 +73,20 @@ "invisible" : "invisible", "Invisible" : "Invisible", "is_also_typing" : "is also typing", - "is_also_typing_male" : "is also typing", "is_also_typing_female" : "is also typing", + "is_also_typing_male" : "is also typing", "is_typing" : "is typing", - "is_typing_male" : "is typing", "is_typing_female" : "is typing", + "is_typing_male" : "is typing", "italics" : "italics", "join" : "Join", "Join_the_Community" : "Join the Community", "Language" : "Language", "Language_Version" : "English Version", - "Last_message" : "Last message", "Last_login" : "Last login", + "Last_message" : "Last message", + "Layout_Home_Body": "Home Body", + "Layout_Home_Title": "Home Title", "Leave_room" : "Leave room", "line" : "line", "Load_more" : "Load more", @@ -98,16 +100,17 @@ "Members_List" : "Members List", "Members_placeholder" : "Members", "Message" : "Message", - "Message_Edit" : "Allow Message Editing", - "Message_Delete" : "Allow Message Deleting", - "Message_ShowEditedStatus" : "Show Edited Status", + "Message_AllowDeleting" : "Allow Message Deleting", + "Message_AllowEditing" : "Allow Message Editing", + "Message_KeepHistory" : "Keep Message History", + "Message_removed" : "Message removed", "Message_ShowDeletedStatus" : "Show Deleted Status", - "Message_KeepStatusHistory" : "Keep Status History", - "Meta_language" : "Language", + "Message_ShowEditedStatus" : "Show Edited Status", "Meta_fb_app_id" : "Facebook APP ID", - "Meta_robots" : "Robots", "Meta_google-site-verification" : "Google Site Verification", + "Meta_language" : "Language", "Meta_msvalidate01" : "MSValidate.01", + "Meta_robots" : "Robots", "More_channels" : "More channels", "Msgs" : "Msgs", "multi" : "multi", @@ -137,15 +140,15 @@ "Profile" : "Profile", "Profile_saved_successfully" : "Profile saved successfully", "Proudly_developed" : "Proudly developed with Meteor", + "Push_apn_cert" : "APN Cert", + "Push_apn_dev_cert" : "APN Dev Cert", + "Push_apn_dev_key" : "APN Dev Key", + "Push_apn_dev_passphrase" : "APN Dev Passphrase", + "Push_apn_key" : "APN Key", + "Push_apn_passphrase" : "APN Passphrase", "Push_debug" : "Debug", "Push_enable" : "Enable", "Push_production" : "Production", - "Push_apn_passphrase" : "APN Passphrase", - "Push_apn_key" : "APN Key", - "Push_apn_cert" : "APN Cert", - "Push_apn_dev_passphrase" : "APN Dev Passphrase", - "Push_apn_dev_key" : "APN Dev Key", - "Push_apn_dev_cert" : "APN Dev Cert", "Quick_Search" : "Quick Search", "quote" : "quote", "Recents" : "Recents", @@ -169,6 +172,7 @@ "Send_confirmation_email" : "Send confirmation email", "Send_Message" : "Send Message", "Settings" : "Settings", + "Settings_updated" : "Settings updated", "Showing_online_users" : "Showing <b>__total_online__</b> of __total__ users", "Showing_results" : "<p>Showing <b>%s</b> results</p>", "Silence" : "Silence", @@ -176,7 +180,6 @@ "SMTP_Host" : "SMTP Host", "SMTP_Password" : "SMTP Password", "SMTP_Port" : "SMTP Port", - "SMTP_Security" : "SMTP Security", "SMTP_Username" : "SMTP Username", "Start_of_conversation" : "Start of conversation", "strike" : "strike", @@ -195,11 +198,11 @@ "User_has_been_activated" : "User has been activated", "User_has_been_deactivated" : "User has been deactivated", "User_joined_channel" : "Has joined the channel.", - "User_joined_channel_male" : "Has joined the channel.", "User_joined_channel_female" : "Has joined the channel.", + "User_joined_channel_male" : "Has joined the channel.", "User_left" : "User <em>__user_left__</em> left.", - "User_left_male" : "User <em>__user_left__</em> left.", "User_left_female" : "User <em>__user_left__</em> left.", + "User_left_male" : "User <em>__user_left__</em> left.", "User_logged_out" : "User is logged out", "User_removed_by" : "User <em>__user_removed__</em> removed by <em>__user_by__</em>.", "User_Settings" : "User Settings", @@ -215,10 +218,10 @@ "Welcome" : "Welcome <em>%s</em>.", "Welcome_to_the" : "Welcome to the", "With_whom" : "With whom", + "Yes_delete_it" : "Yes, delete it!", "you_are_in_preview_mode_of" : "You are in preview mode of channel #<strong>__room_name__</strong>", "You_neeed_confirm_email" : "You need to confirm your email to login!", - "Your_Open_Source_solution" : "Your own Open Source chat solution", "You_will_not_be_able_to_recover" : "You will not be able to recover!", - "Yes_delete_it" : "Yes, delete it!", - "Your_entry_has_been_deleted" : "Your entry has been deleted." + "Your_entry_has_been_deleted" : "Your entry has been deleted.", + "Your_Open_Source_solution" : "Your own Open Source chat solution" } \ No newline at end of file diff --git a/i18n/fi.i18n.json b/i18n/fi.i18n.json index 472df473b6e3105e8e33fa3e291c7bacd43c165c..946f978c81be950daf1cf885967616b5ec925bb8 100644 --- a/i18n/fi.i18n.json +++ b/i18n/fi.i18n.json @@ -98,8 +98,8 @@ "Members_List" : "Jäsenlista", "Members_placeholder" : "Jäsenet", "Message" : "Viesti", - "Message_Edit" : "Salli viestin muokkaus", - "Message_Delete" : "Salli viestin poisto", + "Message_AllowEditing" : "Salli viestin muokkaus", + "Message_AllowDeleting" : "Salli viestin poisto", "Meta_language" : "Kieli", "Meta_fb_app_id" : "Facebook APP ID", "More_channels" : "Lisää kanavia", @@ -169,7 +169,6 @@ "SMTP_Host" : "SMTP-palvelin", "SMTP_Password" : "SMTP Salasana", "SMTP_Port" : "SMTP-portti", - "SMTP_Security" : "SMTP Salaus", "SMTP_Username" : "SMTP Käyttäjätunnus", "Start_of_conversation" : "Keskustelun alku", "strike" : "yliviivaa", diff --git a/i18n/hr.i18n.json b/i18n/hr.i18n.json index 49021ee76b1a918e52b82c11acd3a916dd81f4d1..5e80d84c5353ce02cc270116a300a794f6e3af1e 100644 --- a/i18n/hr.i18n.json +++ b/i18n/hr.i18n.json @@ -95,8 +95,8 @@ "Members_List" : "Lista ÄŒlanova", "Members_placeholder" : "ÄŒlanovi", "Message" : "Poruka", - "Message_Edit" : "Dopusti UreÄ‘ivanje Poruka", - "Message_Delete" : "Dopusti Brisanje Poruka", + "Message_AllowEditing" : "Dopusti UreÄ‘ivanje Poruka", + "Message_AllowDeleting" : "Dopusti Brisanje Poruka", "Message_ShowDeletedStatus" : "Pokaži Izbrisan status", "Meta_language" : "Jezik", "Meta_fb_app_id" : "Facebook App-ID", @@ -162,7 +162,6 @@ "since_creation" : "%s", "SMTP_Password" : "SMTP lozinka", "SMTP_Port" : "SMTP port", - "SMTP_Security" : "SMTP sigurnost", "SMTP_Username" : "SMTP korisniÄko ime", "Start_of_conversation" : "PoÄetak razgovora", "strike" : "precrtaj", diff --git a/i18n/pl.i18n.json b/i18n/pl.i18n.json index b3c187f865e158b49d6e616d88f10c0d2c44b9cd..9249cb65234520608b7ab29390d11403468a29fc 100644 --- a/i18n/pl.i18n.json +++ b/i18n/pl.i18n.json @@ -96,11 +96,11 @@ "Members_List" : "Lista użytkowników", "Members_placeholder" : "CzÅ‚onkowie", "Message" : "Wiadomość", - "Message_Edit" : "Pozwól edytować wiadomość", - "Message_Delete" : "Pozwól usunąć wiadomość", + "Message_AllowEditing" : "Pozwól edytować wiadomość", + "Message_AllowDeleting" : "Pozwól usunąć wiadomość", "Message_ShowEditedStatus" : "Pokaż zmieniony status", "Message_ShowDeletedStatus" : "Pokaż usuniÄ™ty status", - "Message_KeepStatusHistory" : "Zachowaj historiÄ™ statusu", + "Message_KeepHistory" : "Zachowaj historiÄ™ statusu", "More_channels" : "WiÄ™cej kanałów", "Msgs" : "WiadomoÅ›ci", "multi" : "multi", diff --git a/packages/rocketchat-external/app/client/views/message.coffee b/packages/rocketchat-external/app/client/views/message.coffee index 0b3f8c63f6f5bd8eab0290a2f6c4add62c92d3d1..278f4f9cf88d010d65893d5123aeca150517d559 100644 --- a/packages/rocketchat-external/app/client/views/message.coffee +++ b/packages/rocketchat-external/app/client/views/message.coffee @@ -61,7 +61,7 @@ Template.message.onViewRendered = (context) -> ul = lastNode.parentElement wrapper = ul.parentElement - if context.urls?.length > 0 and Template.oembedBaseWidget? and RocketChat.settings.get 'API_Embed' + if context.urls?.length > 0 and Template.oembedBaseWidget? for item in context.urls do (item) -> urlNode = lastNode.querySelector('.body a[href="'+item.url+'"]') diff --git a/packages/rocketchat-lib/settings/server/startup.coffee b/packages/rocketchat-lib/settings/server/startup.coffee index 64e0899eb67d713442829014575d2421cd4d81e2..7645aa1491d7cbc8bc0413f4ad519513506e198f 100644 --- a/packages/rocketchat-lib/settings/server/startup.coffee +++ b/packages/rocketchat-lib/settings/server/startup.coffee @@ -10,16 +10,15 @@ Meteor.startup -> RocketChat.settings.addGroup 'SMTP' RocketChat.settings.add 'SMTP_Host', '', { type: 'string', group: 'SMTP' } RocketChat.settings.add 'SMTP_Port', '', { type: 'string', group: 'SMTP' } - RocketChat.settings.add 'SMTP_Security', '', { type: 'string', group: 'SMTP' } RocketChat.settings.add 'SMTP_Username', '', { type: 'string', group: 'SMTP' } RocketChat.settings.add 'SMTP_Password', '', { type: 'string', group: 'SMTP' } RocketChat.settings.addGroup 'Message' - RocketChat.settings.add 'Message_Edit', '', { type: 'string', group: 'Message' } - RocketChat.settings.add 'Message_Delete', '', { type: 'string', group: 'Message' } - RocketChat.settings.add 'Message_ShowEditedStatus', '', { type: 'string', group: 'Message' } - RocketChat.settings.add 'Message_ShowDeletedStatus', '', { type: 'string', group: 'Message' } - RocketChat.settings.add 'Message_KeepStatusHistory', '', { type: 'string', group: 'Message' } + RocketChat.settings.add 'Message_AllowEditing', true, { type: 'boolean', group: 'Message', public: true } + RocketChat.settings.add 'Message_AllowDeleting', true, { type: 'boolean', group: 'Message', public: true } + RocketChat.settings.add 'Message_ShowEditedStatus', true, { type: 'boolean', group: 'Message', public: true } + RocketChat.settings.add 'Message_ShowDeletedStatus', false, { type: 'boolean', group: 'Message', public: true } + RocketChat.settings.add 'Message_KeepHistory', false, { type: 'boolean', group: 'Message', public: true } RocketChat.settings.add 'Message_MaxAllowedSize', 5000, { type: 'int', group: 'Message', public: true } RocketChat.settings.addGroup 'Meta' @@ -45,3 +44,8 @@ Meteor.startup -> RocketChat.settings.addGroup 'Layout' RocketChat.settings.add 'Layout_Home_Title', 'Home', { type: 'string', group: 'Layout', public: true } RocketChat.settings.add 'Layout_Home_Body', 'Welcome to Rocket.Chat <br> Go to APP SETTINGS -> Layout to customize this intro.', { type: 'string', multiline: true, group: 'Layout', public: true } + + if process?.env? and not process.env['MAIL_URL']? and RocketChat.settings.get('SMTP_Host') and RocketChat.settings.get('SMTP_Username') and RocketChat.settings.get('SMTP_Password') + process.env['MAIL_URL'] = encodeURIComponent(RocketChat.settings.get('SMTP_Username')) + ':' + encodeURIComponent(RocketChat.settings.get('SMTP_Password')) + '@' + encodeURIComponent(RocketChat.settings.get('SMTP_Host')) + if RocketChat.settings.get('SMTP_Port') + process.env['MAIL_URL'] += ':' + parseInt(RocketChat.settings.get('SMTP_Port')) diff --git a/server/methods/deleteMessage.coffee b/server/methods/deleteMessage.coffee index 3fc661054a649321cc2338e0434406e18c80c1d9..0c03266691e072903b65c32e9c99c5d722e91b65 100644 --- a/server/methods/deleteMessage.coffee +++ b/server/methods/deleteMessage.coffee @@ -5,8 +5,39 @@ Meteor.methods console.log '[methods] deleteMessage -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments - ChatMessage.remove - _id: message._id - 'u._id': Meteor.userId() + keepHistory = RocketChat.settings.get 'Message_KeepHistory' + showDeletedStatus = RocketChat.settings.get 'Message_ShowDeletedStatus' - deleteMsgStream.emit message.rid, { _id: message._id } + if keepHistory + if showDeletedStatus + history = ChatMessage.findOne message._id + history._hidden = true + history.parent = history._id + history.ets = new Date() + delete history._id + ChatMessage.insert history + else + ChatMessage.update + _id: message._id + 'u._id': Meteor.userId() + , + $set: + _hidden: true + + else + if not showDeletedStatus + ChatMessage.remove + _id: message._id + 'u._id': Meteor.userId() + + if showDeletedStatus + ChatMessage.update + _id: message._id + 'u._id': Meteor.userId() + , + $set: + msg: '' + t: 'rm' + ets: new Date() + else + deleteMsgStream.emit message.rid, { _id: message._id } diff --git a/server/methods/loadHistory.coffee b/server/methods/loadHistory.coffee index ba1645df85367ade32a113477da715d367ef37b2..5325ca2827ebbed849100d9b8279198dfc30462c 100644 --- a/server/methods/loadHistory.coffee +++ b/server/methods/loadHistory.coffee @@ -7,6 +7,7 @@ Meteor.methods return false query = + _hidden: { $ne: true } rid: rid ts: $lt: end @@ -17,4 +18,7 @@ Meteor.methods limit: limit skip: skip + if not RocketChat.settings.get 'Message_ShowEditedStatus' + options.fields = { ets: 0 } + return ChatMessage.find(query, options).fetch() diff --git a/server/methods/updateMessage.coffee b/server/methods/updateMessage.coffee index 1370fd50a349f412358d550e37843156d345be18..2171d1822dafa7028edd8083373e2224bc317bfa 100644 --- a/server/methods/updateMessage.coffee +++ b/server/methods/updateMessage.coffee @@ -5,6 +5,15 @@ Meteor.methods console.log '[methods] updateMessage -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments + # If we keep history of edits, insert a new message to store history information + if RocketChat.settings.get 'Message_KeepHistory' + history = ChatMessage.findOne message._id + history._hidden = true + history.parent = history._id + history.ets = new Date() + delete history._id + ChatMessage.insert history + message.ets = new Date() if urls = message.msg.match /([A-Za-z]{3,9}):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+=!:~%\/\.@\,\w]+)?\??([-\+=&!:;%@\/\.\,\w]+)?#?([\w]+)?)?/g @@ -13,7 +22,7 @@ Meteor.methods message = RocketChat.callbacks.run 'beforeSaveMessage', message ChatMessage.update - _id: message.id + _id: message._id 'u._id': Meteor.userId() , $set: message diff --git a/server/publications/messages.coffee b/server/publications/messages.coffee index 1b83ebd6546db7bf681f70f61c2c9da72f78cd99..e218ca8cb90aee99a3c74f430b6b40b32ad1dcd9 100644 --- a/server/publications/messages.coffee +++ b/server/publications/messages.coffee @@ -14,7 +14,7 @@ Meteor.publish 'messages', (rid, start) -> cursor = ChatMessage.find rid: rid - _deleted: + _hidden: $ne: true , sort: @@ -30,16 +30,16 @@ Meteor.publish 'messages', (rid, start) -> cursorDelete = ChatMessage.find rid: rid - _deleted: true + _hidden: true , fields: _id: 1 cursorDeleteHandle = cursorDelete.observeChanges added: (_id, record) -> - publication.added('rocketchat_message', _id, {_deleted: true}) + publication.added('rocketchat_message', _id, {_hidden: true}) changed: (_id, record) -> - publication.added('rocketchat_message', _id, {_deleted: true}) + publication.added('rocketchat_message', _id, {_hidden: true}) @ready() @onStop -> diff --git a/server/restapi/restapi.coffee b/server/restapi/restapi.coffee index a546160357d75e2f89c75111fc7d478c30b928d5..8d736b21fd4c5ca927c4713f41c499b0d2ea705b 100644 --- a/server/restapi/restapi.coffee +++ b/server/restapi/restapi.coffee @@ -35,7 +35,7 @@ Api.addRoute 'rooms/:id/messages', authRequired: true, get: -> try if Meteor.call('canAccessRoom', @urlParams.id, this.userId) - msgs = ChatMessage.find({rid: @urlParams.id, _deleted: {$ne: true}}, {sort: {ts: -1}}, {limit: 50}).fetch() + msgs = ChatMessage.find({rid: @urlParams.id, _hidden: {$ne: true}}, {sort: {ts: -1}}, {limit: 50}).fetch() status: 'success', messages: msgs else statusCode: 403 # forbidden diff --git a/server/startup/indexes.coffee b/server/startup/indexes.coffee index 15230eddbbf700d13616355b4f8a2b5525127969..107b1846b89e48a5ae0b0c7d012d09f5a20809d5 100644 --- a/server/startup/indexes.coffee +++ b/server/startup/indexes.coffee @@ -14,4 +14,4 @@ Meteor.startup -> try ChatMessage._ensureIndex { 'ets': 1 }, { sparse: 1 } catch e then console.log e try ChatMessage._ensureIndex { 'rid': 1, 't': 1, 'u._id': 1 } catch e then console.log e try ChatMessage._ensureIndex { 'expireAt': 1 }, { expireAfterSeconds: 0 } catch e then console.log e - try ChatMessage._ensureIndex { '_deleted': 1 }, { sparse: 1 } catch e then console.log e + try ChatMessage._ensureIndex { '_hidden': 1 }, { sparse: 1 } catch e then console.log e diff --git a/server/startup/migrations/v14.coffee b/server/startup/migrations/v14.coffee new file mode 100644 index 0000000000000000000000000000000000000000..99549a4a12ed9ac577807f4cd45f7e6534bfabc5 --- /dev/null +++ b/server/startup/migrations/v14.coffee @@ -0,0 +1,42 @@ +Meteor.startup -> + Migrations.add + version: 14 + up: -> + # Remove unused settings + Settings.remove { _id: "API_Piwik_URL" } + Settings.remove { _id: "API_Piwik_ID" } + + Settings.remove { _id: "Message_Edit" } + Settings.remove { _id: "Message_Delete" } + Settings.remove { _id: "Message_KeepStatusHistory" } + + Settings.update { _id: "Message_ShowEditedStatus" }, { $set: { type: "boolean", value: true } } + Settings.update { _id: "Message_ShowDeletedStatus" }, { $set: { type: "boolean", value: false } } + + metaKeys = [ + 'old': 'Meta:language' + 'new': 'Meta_language' + , + 'old': 'Meta:fb:app_id' + 'new': 'Meta_fb_app_id' + , + 'old': 'Meta:robots' + 'new': 'Meta_robots' + , + 'old': 'Meta:google-site-verification' + 'new': 'Meta_google-site-verification' + , + 'old': 'Meta:msvalidate.01' + 'new': 'Meta_msvalidate01' + ] + + for oldAndNew in metaKeys + oldValue = Settings.findOne({_id: oldAndNew.old})?.value + newValue = Settings.findOne({_id: oldAndNew.new})?.value + if oldValue? and not newValue? + Settings.update { _id: oldAndNew.new }, { $set: { value: newValue } } + + Settings.remove { _id: oldAndNew.old } + + + Settings.remove { _id: "SMTP_Security" } diff --git a/server/stream/messages.coffee b/server/stream/messages.coffee index 848d7e5264f9e68603bc39ea2eb8b64f3da765e8..6c514272f7dfb519efcfe71120cf9ff004666c01 100644 --- a/server/stream/messages.coffee +++ b/server/stream/messages.coffee @@ -33,6 +33,7 @@ deleteMsgStream.permissions.read (eventName) -> Meteor.startup -> filter = + _hidden: { $ne: true } $or: [ ts: $gt: new Date() @@ -43,6 +44,9 @@ Meteor.startup -> options = {} + if not RocketChat.settings.get 'Message_ShowEditedStatus' + options.fields = { ets: 0 } + ChatMessage.find(filter, options).observe added: (record) -> msgStream.emit record.rid, record