Skip to content

Commit

Permalink
[FIX] Handle decline message action link (#22936)
Browse files Browse the repository at this point in the history
* [NEW] Control Buttons - mic, cam, expand and end call

* [REFACTOR] Add an empty file on EOF en18.i18n that was mistakenly removed

* [FIX] UI Responsiveness

* [REF] Use const and ternary op

* [FIX] Action Link not updating when call declined

* [FIX] WebRTC_call_declined_message

Co-authored-by: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com>

* [REF] Use a single IF statement to handle status

Co-authored-by: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com>
  • Loading branch information
dhruvjain99 and murtaza98 committed Nov 22, 2021
1 parent c08c979 commit 909ec4a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/livechat/lib/messageTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ MessageTypes.registerType({
MessageTypes.registerType({
id: 'livechat_webrtc_video_call',
render(message) {
if (message.endTs) {
if (message.msg === 'ended' && message.endTs) {
const hh = parseInt(Math.abs(message.endTs - message.ts) / 36e5);
const mm = parseInt(Math.abs(message.endTs - message.ts) / 6e4) % 60;
const ss = parseInt(Math.abs(message.endTs - message.ts) / 1000) % 60;
Expand All @@ -99,6 +99,9 @@ MessageTypes.registerType({
}
return TAPi18n.__('WebRTC_call_ended_message', { callDuration, endTime: moment(message.endTs).format('h:mm A') });
}
if (message.msg === 'declined' && message.endTs) {
return TAPi18n.__('WebRTC_call_declined_message');
}
return message.msg;
},
});
Expand Down
5 changes: 3 additions & 2 deletions app/livechat/server/api/v1/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ API.v1.addRoute('livechat/visitor.callStatus', {
token: String,
callStatus: String,
rid: String,
callId: String,
});

const { token, callStatus, rid } = this.bodyParams;
const { token, callStatus, rid, callId } = this.bodyParams;
const guest = findGuest(token);
if (!guest) {
throw new Meteor.Error('invalid-token');
}
const status = callStatus;
Livechat.updateCallStatus('', rid, status);
Livechat.updateCallStatus(callId, rid, status, guest);
return API.v1.success({ token, callStatus });
} catch (e) {
return API.v1.failure(e);
Expand Down
6 changes: 3 additions & 3 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1278,10 +1278,10 @@ export const Livechat = {
};
LivechatVisitors.updateById(contactId, updateUser);
},
updateCallStatus(callId, rid, status, user = null) {
updateCallStatus(callId, rid, status, user) {
Rooms.setCallStatus(rid, status);
if (status === 'ended' && user) {
return updateMessage({ _id: callId, msg: '', actionLinks: [], endTs: new Date() }, user);
if (status === 'ended' || status === 'declined') {
return updateMessage({ _id: callId, msg: status, actionLinks: [], endTs: new Date() }, user);
}
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4661,6 +4661,7 @@
"WebRTC_Servers": "STUN/TURN Servers",
"WebRTC_Servers_Description": "A list of STUN and TURN servers separated by comma.<br/>Username, password and port are allowed in the format `username:password@stun:host:port` or `username:password@turn:host:port`.",
"WebRTC_call_ended_message": "<i class=\"icon-phone\"></i> Call ended at __endTime__ - Lasted __callDuration__",
"WebRTC_call_declined_message": "<i class=\"icon-phone\"></i> Call Declined by Contact.",
"Website": "Website",
"Wednesday": "Wednesday",
"Weekly_Active_Users": "Weekly Active Users",
Expand Down

0 comments on commit 909ec4a

Please sign in to comment.