Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into regr…
Browse files Browse the repository at this point in the history
…ession/uikit

* 'develop' of github.com:RocketChat/Rocket.Chat:
  Regression: Ui Kit messaging issues #16513
  • Loading branch information
ggazzo committed Feb 7, 2020
2 parents decddd2 + 25f01ea commit 0159c37
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/authorization/server/functions/canSendMessage.js
Expand Up @@ -9,10 +9,10 @@ const subscriptionOptions = {
},
};

export const canSendMessageAsync = async (rid, { uid, username }, extraData) => {
export const canSendMessageAsync = async (rid, { uid, username, type }, extraData) => {
const room = await Rooms.findOneById(rid);

if (!await canAccessRoomAsync(room, { _id: uid, username }, extraData)) {
if (type !== 'app' && !await canAccessRoomAsync(room, { _id: uid, username }, extraData)) {
throw new Error('error-not-allowed');
}

Expand All @@ -35,4 +35,4 @@ export const canSendMessageAsync = async (rid, { uid, username }, extraData) =>
return room;
};

export const canSendMessage = (rid, { uid, username }, extraData) => Promise.await(canSendMessageAsync(rid, { uid, username }, extraData));
export const canSendMessage = (rid, { uid, username, type }, extraData) => Promise.await(canSendMessageAsync(rid, { uid, username, type }, extraData));
10 changes: 5 additions & 5 deletions app/lib/server/functions/deleteMessage.js
@@ -1,10 +1,10 @@
import { Meteor } from 'meteor/meteor';

import { FileUpload } from '../../../file-upload';
import { settings } from '../../../settings';
import { Messages, Uploads, Rooms } from '../../../models';
import { Notifications } from '../../../notifications';
import { callbacks } from '../../../callbacks';
import { FileUpload } from '../../../file-upload/server';
import { settings } from '../../../settings/server';
import { Messages, Uploads, Rooms } from '../../../models/server';
import { Notifications } from '../../../notifications/server';
import { callbacks } from '../../../callbacks/server';
import { Apps } from '../../../apps/server';

export const deleteMessage = function(message, user) {
Expand Down
3 changes: 2 additions & 1 deletion app/lib/server/methods/sendMessage.js
Expand Up @@ -50,6 +50,7 @@ export function executeSendMessage(uid, message) {
const user = Users.findOneById(uid, {
fields: {
username: 1,
type: 1,
...!!settings.get('Message_SetNameToAliasEnabled') && { name: 1 },
},
});
Expand All @@ -67,7 +68,7 @@ export function executeSendMessage(uid, message) {
}

try {
const room = canSendMessage(rid, { uid, username: user.username });
const room = canSendMessage(rid, { uid, username: user.username, type: user.type });
if (message.alias == null && settings.get('Message_SetNameToAliasEnabled')) {
message.alias = user.name;
}
Expand Down
3 changes: 3 additions & 0 deletions app/models/server/models/Messages.js
Expand Up @@ -561,6 +561,9 @@ export class Messages extends Base {
username: user.username,
},
},
$unset: {
blocks: 1,
},
};

return this.update(query, update);
Expand Down
11 changes: 6 additions & 5 deletions app/ui-message/client/message.html
Expand Up @@ -75,15 +75,16 @@
{{#if isSnippet}}
<div class="snippet-name">{{_ "Snippet_name"}}: {{snippetName}}</div>
{{/if}}
{{#if isDecrypting}}
<span>******</span>
{{else}}
{{{body}}}
{{/if}}
{{#if msg.blocks}}
<div class='rc-ui-kit'>
{{> Blocks blocks=msg.blocks rid=msg.rid mid=msg._id}}
</div>
{{else}}
{{#if isDecrypting}}
<span>******</span>
{{else}}
{{{body}}}
{{/if}}
{{/if}}
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -122,7 +122,7 @@
"@google-cloud/language": "^3.7.0",
"@google-cloud/storage": "^2.3.1",
"@google-cloud/vision": "^1.8.0",
"@rocket.chat/apps-engine": "^1.12.0-beta.2685",
"@rocket.chat/apps-engine": "^1.12.0-beta.2703",
"@rocket.chat/fuselage": "^0.2.0-alpha.22",
"@rocket.chat/fuselage-hooks": "^0.2.0-alpha.22",
"@rocket.chat/fuselage-ui-kit": "^0.2.0-alpha.22",
Expand Down

0 comments on commit 0159c37

Please sign in to comment.