Skip to content

Commit

Permalink
feat: Persistent Chat Discussion Name wildcard (#33920)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchoeler authored Nov 18, 2024
1 parent 6c83bf0 commit 661cc01
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/silent-steaks-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/i18n": minor
---

Improves the customizability of the naming of automatic Persistent video calls discussions, allowing the date of the call to be in different parts of the name, using the `[date]` keyword.
3 changes: 2 additions & 1 deletion apps/meteor/ee/server/settings/video-conference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ export function addSettings(): Promise<void> {

const persistentChatEnabled = { _id: 'VideoConf_Enable_Persistent_Chat', value: true };

await this.add('VideoConf_Persistent_Chat_Discussion_Name', 'Conference Call Chat History', {
await this.add('VideoConf_Persistent_Chat_Discussion_Name', 'Video Call Chat', {
type: 'string',
public: true,
invalidValue: 'Conference Call Chat History',
i18nDescription: 'VideoConf_Persistent_Chat_Discussion_Name_Description',
enableQuery: [discussionsEnabled, persistentChatEnabled],
});
},
Expand Down
11 changes: 9 additions & 2 deletions apps/meteor/server/services/video-conference/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,15 @@ export class VideoConfService extends ServiceClassInternal implements IVideoConf
return;
}

const name = settings.get<string>('VideoConf_Persistent_Chat_Discussion_Name') || i18n.t('Conference Call Chat History');
const displayName = `${name} - ${new Date().toISOString().substring(0, 10)}`;
const name = settings.get<string>('VideoConf_Persistent_Chat_Discussion_Name') || i18n.t('[date] Video Call Chat');
let displayName;
const date = new Date().toISOString().substring(0, 10);

if (name.includes('[date]')) {
displayName = name.replace('[date]', date);
} else {
displayName = `${date} ${name}`;
}

await this.createDiscussionForConference(displayName, call, createdBy);
}
Expand Down
77 changes: 75 additions & 2 deletions apps/meteor/tests/end-to-end/apps/video-conferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Apps - Video Conferences', () => {
}

await updateSetting('VideoConf_Enable_Persistent_Chat', false);
await updateSetting('VideoConf_Persistent_Chat_Discussion_Name', 'Conference Call Chat History');
await updateSetting('VideoConf_Persistent_Chat_Discussion_Name', '[date] - Video Call Persisted Chat');
});

describe('[/video-conference.capabilities]', () => {
Expand Down Expand Up @@ -577,7 +577,80 @@ describe('Apps - Video Conferences', () => {
expect(res.body.room)
.to.have.a.property('fname')
.that.is.a('string')
.that.satisfies((msg: string) => msg.startsWith('Chat History'));
.that.satisfies((msg: string) => !msg.startsWith('Chat History'))
.that.satisfies((msg: string) => msg.includes('Chat History'));
});
});
});

describe('[Persistent Chat provider with the persistent chat feature enabled and custom discussion names]', () => {
let callId: string | undefined;
let discussionRid: string | undefined;
let chatDate: string;

before(async () => {
if (!process.env.IS_EE) {
return;
}

await updateSetting('VideoConf_Default_Provider', 'persistentchat');
await updateSetting('Discussion_enabled', true);
await updateSetting('VideoConf_Enable_Persistent_Chat', true);
await updateSetting('VideoConf_Persistent_Chat_Discussion_Name', 'Date [date] between');
chatDate = new Date().toISOString().substring(0, 10);
const res = await request.post(api('video-conference.start')).set(credentials).send({
roomId,
});

callId = res.body.data.callId;
});

it('should include a discussion room id on the response', async function () {
if (!process.env.IS_EE) {
this.skip();
return;
}

await request
.get(api('video-conference.info'))
.set(credentials)
.query({
callId,
})
.expect(200)
.expect((res: Response) => {
expect(res.body.success).to.be.equal(true);
expect(res.body).to.have.a.property('providerName').equal('persistentchat');
expect(res.body).to.not.have.a.property('providerData');
expect(res.body).to.have.a.property('_id').equal(callId);
expect(res.body).to.have.a.property('discussionRid').that.is.a('string');

discussionRid = res.body.discussionRid;
expect(res.body).to.have.a.property('url').equal(`pchat/videoconference/${callId}/${discussionRid}`);
});
});

it('should have created the discussion room using the configured name', async function () {
if (!process.env.IS_EE) {
this.skip();
return;
}

await request
.get(api('rooms.info'))
.set(credentials)
.query({
roomId: discussionRid,
})
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('room').and.to.be.an('object');
expect(res.body.room).to.have.a.property('_id').equal(discussionRid);
expect(res.body.room)
.to.have.a.property('fname')
.that.is.a('string')
.that.satisfies((msg: string) => msg.includes(`Date ${chatDate} between`));
});
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5880,6 +5880,7 @@
"VideoConf_Enable_Persistent_Chat_description": "When persistent chat is enabled, Rocket.Chat will create a discussion every time a conference call is initiated. The provider app is responsible for sending the chat messages to this discussion.",
"VideoConf_Enable_Persistent_Chat_Alert": "Persistent Chat will not work if discussions are disabled on the workspace. It will also not work if the provider app being used do not explicitly support this feature.",
"VideoConf_Persistent_Chat_Discussion_Name": "Persistent Chat Discussion Name",
"VideoConf_Persistent_Chat_Discussion_Name_Description": "Use [date] tag to set where to include the date. Date will be added to the start if tag is not included.",
"VideoConf_Mobile_Ringing": "Enable mobile ringing",
"VideoConf_Mobile_Ringing_Description": "When enabled, direct calls to mobile users will ring their device as a phone call.",
"VideoConf_Mobile_Ringing_Alert": "This feature is currently in an experimental stage and may not yet be fully supported by the mobile app. When enabled it will send additional Push Notifications to users.",
Expand Down

0 comments on commit 661cc01

Please sign in to comment.