diff --git a/src/CONST.js b/src/CONST.js index 5b1b82da5904..4afd615db61a 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -384,6 +384,7 @@ const CONST = { PUSHER: { PRIVATE_USER_CHANNEL_PREFIX: 'private-encrypted-user-accountID-', + PRIVATE_REPORT_CHANNEL_PREFIX: 'private-report-reportID-', }, EMOJI_SPACER: 'SPACER', diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 3abd3ba12356..aa61d3134fac 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -589,7 +589,7 @@ function updateReportWithNewAction( * @returns {String} */ function getReportChannelName(reportID) { - return `private-report-reportID-${reportID}${CONFIG.PUSHER.SUFFIX}`; + return `${CONST.PUSHER.PRIVATE_REPORT_CHANNEL_PREFIX}${reportID}${CONFIG.PUSHER.SUFFIX}`; } /** @@ -601,7 +601,7 @@ function subscribeToUserEvents() { return; } - const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`; + const pusherChannelName = `${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`; if (Pusher.isSubscribed(pusherChannelName) || Pusher.isAlreadySubscribing(pusherChannelName)) { return; } diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 777bd268b9f3..863c75886cb5 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -302,7 +302,7 @@ function subscribeToUserEvents() { return; } - const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`; + const pusherChannelName = `${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`; // Receive any relevant Onyx updates from the server PusherUtils.subscribeToPrivateUserChannelEvent(Pusher.TYPE.ONYX_API_UPDATE, currentUserAccountID, (pushJSON) => { @@ -355,7 +355,7 @@ function subscribeToExpensifyCardUpdates() { return; } - const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`; + const pusherChannelName = `${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`; // Handle Expensify Card approval flow updates Pusher.subscribe(pusherChannelName, Pusher.TYPE.EXPENSIFY_CARD_UPDATE, (pushJSON) => { diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js index 0b71dca9e328..6af615bf866b 100644 --- a/tests/actions/ReportTest.js +++ b/tests/actions/ReportTest.js @@ -43,7 +43,7 @@ describe('actions/Report', () => { afterEach(() => { // Unsubscribe from account channel after each test since we subscribe in the function // subscribeToUserEvents and we don't want duplicate event subscriptions. - Pusher.unsubscribe(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`); + Pusher.unsubscribe(`${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}1${CONFIG.PUSHER.SUFFIX}`); }); it('should store a new report action in Onyx when reportComment event is handled via Pusher', () => { @@ -106,7 +106,7 @@ describe('actions/Report', () => { .then(() => { // We subscribed to the Pusher channel above and now we need to simulate a reportComment action // Pusher event so we can verify that action was handled correctly and merged into the reportActions. - const channel = Pusher.getChannel(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`); + const channel = Pusher.getChannel(`${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}1${CONFIG.PUSHER.SUFFIX}`); channel.emit(Pusher.TYPE.REPORT_COMMENT, { reportID: REPORT_ID, reportAction: {...REPORT_ACTION, clientID},