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

feat: Create Ephemeral Message for mentioned users that are not in the channel #30412

Closed
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
71 changes: 71 additions & 0 deletions apps/meteor/client/views/room/composer/ComposerMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { IMessage, IRoom, ISubscription } from '@rocket.chat/core-typings';
import { Random } from '@rocket.chat/random';
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import React, { memo, useCallback, useMemo } from 'react';
Expand Down Expand Up @@ -52,7 +53,77 @@ const ComposerMessage = ({ rid, tmid, readOnly, onSend, ...props }: ComposerMess
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}

// Check mention function
// const regex = new RegExp(`(^|\\s|>)@(${settings.get('UTF8_User_Names_Validation')}(@(${settings.get('UTF8_User_Names_Validation')}))?(:([0-9a-zA-Z-_.]+))?)`, 'gm');
const mentionsList = text.match(/@[0-9a-zA-Z-_.]+/gi);
console.log('resp', mentionsList);

// Check if user is in the channel
// -- Code --

// Send message
await chat?.data.pushEphemeralMessage({
_id: Random.id(),
ts: new Date(),
msg: 'Message here',
u: {
_id: 'rocket.cat',
username: 'rocket.cat',
name: 'Rocket.Cat',
},
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: 'You mentioned *Rachel Berry*, but they are not in this room <https://google.com|this is a link>',
},
},
{
type: 'actions',
elements: [
{
type: 'button',
appId: 'app-id',
blockId: 'block-id',
actionId: 'action-id',
text: {
type: 'plain_text',
text: 'Add them',
},
url: 'teste',
},
{
type: 'button',
appId: 'app-id',
blockId: 'block-id',
actionId: 'action-id',
text: {
type: 'plain_text',
text: 'Do nothing',
},
url: 'teste',
},
{
type: 'button',
appId: 'app-id',
blockId: 'block-id',
actionId: 'action-id',
text: {
type: 'plain_text',
text: 'Let them know',
},
url: 'teste',
},
],
},
],
private: true,
_updatedAt: new Date(),
});
},

onTyping: async (): Promise<void> => {
if (chat?.composer?.text?.trim() === '') {
await chat?.action.stop('typing');
Expand Down