-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into globals/ui-package
# Conflicts: # packages/rocketchat-authorization/client/index.js # packages/rocketchat-file-upload/package.js # packages/rocketchat-file-upload/server/index.js # packages/rocketchat-lib/client/MessageAction.js # packages/rocketchat-lib/lib/slashCommand.js # packages/rocketchat-lib/package.js # packages/rocketchat-ui-message/package.js # packages/rocketchat-ui-sidenav/package.js # packages/rocketchat-ui-utils/client/index.js # packages/rocketchat-ui-utils/client/lib/RoomManager.js # packages/rocketchat-ui-utils/lib/MessageProperties.js # packages/rocketchat-ui/client/lib/menu.js # packages/rocketchat-ui/client/views/app/room.js # packages/rocketchat-utils/lib/RoomTypeConfig.js # packages/rocketchat-utils/lib/slashCommand.js
- Loading branch information
Showing
26 changed files
with
104 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,247 +1,3 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { TAPi18n } from 'meteor/tap:i18n'; | ||
import { Session } from 'meteor/session'; | ||
import { t } from 'meteor/rocketchat:utils'; | ||
import { MessageAction } from 'meteor/rocketchat:ui-utils'; | ||
import moment from 'moment'; | ||
import toastr from 'toastr'; | ||
|
||
const success = function success(fn) { | ||
return function(error, result) { | ||
if (error) { | ||
return handleError(error); | ||
} | ||
if (result) { | ||
fn.call(this, result); | ||
} | ||
}; | ||
}; | ||
|
||
RocketChat.MessageAction = MessageAction; | ||
|
||
Meteor.startup(function() { | ||
RocketChat.MessageAction.addButton({ | ||
id: 'reply-message', | ||
icon: 'message', | ||
label: 'Reply', | ||
context: ['message', 'message-mobile'], | ||
action() { | ||
const message = this._arguments[1]; | ||
const { input } = chatMessages[message.rid]; | ||
$(input) | ||
.focus() | ||
.data('mention-user', true) | ||
.data('reply', message) | ||
.trigger('dataChange'); | ||
}, | ||
condition(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}, | ||
order: 1, | ||
group: 'menu', | ||
}); | ||
|
||
RocketChat.MessageAction.addButton({ | ||
id: 'edit-message', | ||
icon: 'edit', | ||
label: 'Edit', | ||
context: ['message', 'message-mobile'], | ||
action() { | ||
const messageId = this._arguments[1]._id; | ||
chatMessages[Session.get('openedRoom')].edit(document.getElementById(messageId)); | ||
}, | ||
condition(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ | ||
rid: message.rid, | ||
}) == null) { | ||
return false; | ||
} | ||
const hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', message.rid); | ||
const isEditAllowed = RocketChat.settings.get('Message_AllowEditing'); | ||
const editOwn = message.u && message.u._id === Meteor.userId(); | ||
if (!(hasPermission || (isEditAllowed && editOwn))) { | ||
return; | ||
} | ||
const blockEditInMinutes = RocketChat.settings.get('Message_AllowEditing_BlockEditInMinutes'); | ||
if (blockEditInMinutes) { | ||
let msgTs; | ||
if (message.ts != null) { | ||
msgTs = moment(message.ts); | ||
} | ||
let currentTsDiff; | ||
if (msgTs != null) { | ||
currentTsDiff = moment().diff(msgTs, 'minutes'); | ||
} | ||
return currentTsDiff < blockEditInMinutes; | ||
} else { | ||
return true; | ||
} | ||
}, | ||
order: 2, | ||
group: 'menu', | ||
}); | ||
|
||
RocketChat.MessageAction.addButton({ | ||
id: 'delete-message', | ||
icon: 'trash', | ||
label: 'Delete', | ||
context: ['message', 'message-mobile'], | ||
color: 'alert', | ||
action() { | ||
const message = this._arguments[1]; | ||
chatMessages[Session.get('openedRoom')].confirmDeleteMsg(message); | ||
}, | ||
condition(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
const forceDelete = RocketChat.authz.hasAtLeastOnePermission('force-delete-message', message.rid); | ||
const hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid); | ||
const isDeleteAllowed = RocketChat.settings.get('Message_AllowDeleting'); | ||
const deleteOwn = message.u && message.u._id === Meteor.userId(); | ||
if (!(hasPermission || (isDeleteAllowed && deleteOwn) || forceDelete)) { | ||
return; | ||
} | ||
const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes'); | ||
if (forceDelete) { | ||
return true; | ||
} | ||
if (blockDeleteInMinutes != null && blockDeleteInMinutes !== 0) { | ||
let msgTs; | ||
if (message.ts != null) { | ||
msgTs = moment(message.ts); | ||
} | ||
let currentTsDiff; | ||
if (msgTs != null) { | ||
currentTsDiff = moment().diff(msgTs, 'minutes'); | ||
} | ||
return currentTsDiff < blockDeleteInMinutes; | ||
} else { | ||
return true; | ||
} | ||
}, | ||
order: 3, | ||
group: 'menu', | ||
}); | ||
|
||
RocketChat.MessageAction.addButton({ | ||
id: 'permalink', | ||
icon: 'permalink', | ||
label: 'Permalink', | ||
classes: 'clipboard', | ||
context: ['message', 'message-mobile'], | ||
async action(event) { | ||
const message = this._arguments[1]; | ||
const permalink = await RocketChat.MessageAction.getPermaLink(message._id); | ||
if (Meteor.isCordova) { | ||
cordova.plugins.clipboard.copy(permalink); | ||
} else { | ||
$(event.currentTarget).attr('data-clipboard-text', permalink); | ||
} | ||
toastr.success(TAPi18n.__('Copied')); | ||
}, | ||
condition(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}, | ||
order: 4, | ||
group: 'menu', | ||
}); | ||
|
||
RocketChat.MessageAction.addButton({ | ||
id: 'copy', | ||
icon: 'copy', | ||
label: 'Copy', | ||
classes: 'clipboard', | ||
context: ['message', 'message-mobile'], | ||
action(event) { | ||
const message = this._arguments[1].msg; | ||
if (Meteor.isCordova) { | ||
cordova.plugins.clipboard.copy(message); | ||
} else { | ||
$(event.currentTarget).attr('data-clipboard-text', message); | ||
} | ||
toastr.success(TAPi18n.__('Copied')); | ||
}, | ||
condition(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}, | ||
order: 5, | ||
group: 'menu', | ||
}); | ||
|
||
RocketChat.MessageAction.addButton({ | ||
id: 'quote-message', | ||
icon: 'quote', | ||
label: 'Quote', | ||
context: ['message', 'message-mobile'], | ||
action() { | ||
const message = this._arguments[1]; | ||
const { input } = chatMessages[message.rid]; | ||
$(input) | ||
.focus() | ||
.data('mention-user', false) | ||
.data('reply', message) | ||
.trigger('dataChange'); | ||
}, | ||
condition(message) { | ||
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}, | ||
order: 6, | ||
group: 'menu', | ||
}); | ||
|
||
|
||
RocketChat.MessageAction.addButton({ | ||
id: 'ignore-user', | ||
icon: 'ban', | ||
label: t('Ignore'), | ||
context: ['message', 'message-mobile'], | ||
action() { | ||
const [, { rid, u: { _id } }] = this._arguments; | ||
Meteor.call('ignoreUser', { rid, userId:_id, ignore: true }, success(() => toastr.success(t('User_has_been_ignored')))); | ||
}, | ||
condition(message) { | ||
const subscription = RocketChat.models.Subscriptions.findOne({ rid: message.rid }); | ||
|
||
return Meteor.userId() !== message.u._id && !(subscription && subscription.ignored && subscription.ignored.indexOf(message.u._id) > -1); | ||
}, | ||
order: 20, | ||
group: 'menu', | ||
}); | ||
|
||
RocketChat.MessageAction.addButton({ | ||
id: 'unignore-user', | ||
icon: 'ban', | ||
label: t('Unignore'), | ||
context: ['message', 'message-mobile'], | ||
action() { | ||
const [, { rid, u: { _id } }] = this._arguments; | ||
Meteor.call('ignoreUser', { rid, userId:_id, ignore: false }, success(() => toastr.success(t('User_has_been_unignored')))); | ||
|
||
}, | ||
condition(message) { | ||
const subscription = RocketChat.models.Subscriptions.findOne({ rid: message.rid }); | ||
return Meteor.userId() !== message.u._id && subscription && subscription.ignored && subscription.ignored.indexOf(message.u._id) > -1; | ||
}, | ||
order: 20, | ||
group: 'menu', | ||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { slashCommands } from 'meteor/rocketchat:utils'; | ||
|
||
RocketChat.slashCommands = slashCommands; | ||
|
||
Meteor.methods({ | ||
slashCommand(command) { | ||
if (!Meteor.userId()) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
method: 'slashCommand', | ||
}); | ||
} | ||
|
||
if (!command || !command.cmd || !RocketChat.slashCommands.commands[command.cmd]) { | ||
throw new Meteor.Error('error-invalid-command', 'Invalid Command Provided', { | ||
method: 'executeSlashCommandPreview', | ||
}); | ||
} | ||
|
||
return RocketChat.slashCommands.run(command.cmd, command.params, command.msg); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.