From 2b1c875b91468f3cd2f53eeb0aec3b6e550f1adc Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Mon, 21 May 2018 15:48:24 -0500 Subject: [PATCH] feat(presence-status): Add more statuses. --- lang/main.json | 6 +- react/features/presence-status/constants.js | 88 +++++++++++++++---- .../prosody-plugins/mod_muc_poltergeist.lua | 35 +++----- 3 files changed, 88 insertions(+), 41 deletions(-) diff --git a/lang/main.json b/lang/main.json index 936ee4dd8..c97157d1e 100644 --- a/lang/main.json +++ b/lang/main.json @@ -587,10 +587,14 @@ "invited": "Invited", "ringing": "Ringing", "calling": "Calling", + "initializingCall": "Initializing Call", "connected": "Connected", "connecting": "Connecting", + "connecting2": "Connecting*", + "disconnected": "Disconnected", "busy": "Busy", "rejected": "Rejected", - "ignored": "Ignored" + "ignored": "Ignored", + "expired": "Expired" } } diff --git a/react/features/presence-status/constants.js b/react/features/presence-status/constants.js index 159b0673e..f6b6522ef 100644 --- a/react/features/presence-status/constants.js +++ b/react/features/presence-status/constants.js @@ -1,3 +1,5 @@ +// User invite statuses + /** * Тhe status for a participant when it's invited to a conference. * @@ -22,11 +24,50 @@ export const RINGING = 'Ringing'; /** * A status for a participant that indicates the call is connected. + * + * @type {string} + */ +export const CONNECTED_USER = 'connected'; + +/** + * The status for a participant when the invitation is received but the user + * has responded with busy message. + * + * @type {string} + */ +export const BUSY = 'Busy'; + +/** + * The status for a participant when the invitation is rejected. + * + * @type {string} + */ +export const REJECTED = 'Rejected'; + +/** + * The status for a participant when the invitation is ignored. + * + * @type {string} + */ +export const IGNORED = 'Ignored'; + +/** + * The status for a participant when the invitation is expired. + * + * @type {string} + */ +export const EXPIRED = 'Expired'; + +// Phone call statuses + +/** + * A status for a participant that indicates the call is in process of + * initialization. * NOTE: Currently used for phone numbers only. * * @type {string} */ -export const CONNECTED = 'Connected'; +export const INITIALIZING_CALL = 'Initializing Call'; /** * A status for a participant that indicates the call is in process of @@ -38,20 +79,30 @@ export const CONNECTED = 'Connected'; export const CONNECTING = 'Connecting'; /** - * The status for a participant when the invitation is received but the user - * has responded with busy message. + * A status for a participant that indicates the call is in process of + * connecting. + * NOTE: Currently used for phone numbers only. + * + * @type {string} */ -export const BUSY = 'Busy'; +export const CONNECTING2 = 'Connecting*'; + /** - * The status for a participant when the invitation is rejected. + * A status for a phone number participant that indicates the call is connected. + * + * @type {string} */ -export const REJECTED = 'Rejected'; +export const CONNECTED_PHONE_NUMBER = 'Connected'; + /** - * The status for a participant when the invitation is ignored. + * A status for a participant that indicates the call is disconnected. + * NOTE: Currently used for phone numbers only. + * + * @type {string} */ -export const IGNORED = 'Ignored'; +export const DISCONNECTED = 'Disconnected'; /** * Maps the presence status values to i18n translation keys. @@ -59,12 +110,17 @@ export const IGNORED = 'Ignored'; * @type {Object} */ export const STATUS_TO_I18N_KEY = { - 'Invited': 'presenceStatus.invited', - 'Ringing': 'presenceStatus.ringing', - 'Calling': 'presenceStatus.calling', - 'Connected': 'presenceStatus.connected', - 'Connecting': 'presenceStatus.connecting', - 'Busy': 'presenceStatus.busy', - 'Rejected': 'presenceStatus.rejected', - 'Ignored': 'presenceStatus.ignored' + [INVITED]: 'presenceStatus.invited', + [RINGING]: 'presenceStatus.ringing', + [CALLING]: 'presenceStatus.calling', + [BUSY]: 'presenceStatus.busy', + [REJECTED]: 'presenceStatus.rejected', + [IGNORED]: 'presenceStatus.ignored', + [EXPIRED]: 'presenceStatus.expired', + + [INITIALIZING_CALL]: 'presenceStatus.initializingCall', + [CONNECTING]: 'presenceStatus.connecting', + [CONNECTING2]: 'presenceStatus.connecting2', + [CONNECTED_PHONE_NUMBER]: 'presenceStatus.connected', + [DISCONNECTED]: 'presenceStatus.disconnected' }; diff --git a/resources/prosody-plugins/mod_muc_poltergeist.lua b/resources/prosody-plugins/mod_muc_poltergeist.lua index 252800908..ac64f1425 100644 --- a/resources/prosody-plugins/mod_muc_poltergeist.lua +++ b/resources/prosody-plugins/mod_muc_poltergeist.lua @@ -36,10 +36,6 @@ local token_util = module:require "token/util".new(parentCtx); local disableTokenVerification = module:get_option_boolean("disable_polergeist_token_verification", false); --- option to expire poltergeist with custom status text -local poltergeistExpiredStatus - = module:get_option_string("poltergeist_expired_status"); - -- table to store all poltergeists we create local poltergeists = {}; -- table to mark that outgoing unavailable presences @@ -240,31 +236,22 @@ function create_poltergeist_occupant(room, nick, name, avatar, status, context) room:handle_first_presence( prosody.hosts[poltergeist_component], join_presence); - local timeout = poltergeist_timeout; -- the timeout before removing so participants can see the status update local removeTimeout = 5; - if (poltergeistExpiredStatus) then - timeout = timeout - removeTimeout; - end + local timeout = poltergeist_timeout - removeTimeout; timer.add_task(timeout, function () - if (poltergeistExpiredStatus) then - update_poltergeist_occupant_status( - room, nick, poltergeistExpiredStatus); - -- and remove it after some time so participant can see - -- the update - timer.add_task(removeTimeout, - function () - if (have_poltergeist_occupant(room, nick)) then - remove_poltergeist_occupant(room, nick, false); - end - end); - else - if (have_poltergeist_occupant(room, nick)) then - remove_poltergeist_occupant(room, nick, false); - end - end + update_poltergeist_occupant_status( + room, nick, "Expired"); + -- and remove it after some time so participant can see + -- the update + timer.add_task(removeTimeout, + function () + if (have_poltergeist_occupant(room, nick)) then + remove_poltergeist_occupant(room, nick, false); + end + end); end); end