Skip to content

Commit

Permalink
Merge pull request #8982 from Expensify/yuwen-moveToEncrypted
Browse files Browse the repository at this point in the history
Move Pusher to Use Encrypted Channels
  • Loading branch information
Beamanator authored May 13, 2022
2 parents 30f79b3 + ca3fa32 commit d8274f5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/libs/Pusher/library/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
* We use the standard pusher-js module to support pusher on web environments.
* @see: https://github.com/pusher/pusher-js
*/
import Pusher from 'pusher-js';
import Pusher from 'pusher-js/with-encryption';

export default Pusher;
4 changes: 2 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ function getReportChannelName(reportID) {
* @param {Boolean} isChunked
*/
function subscribeToPrivateUserChannelEvent(eventName, onEvent, isChunked = false) {
const pusherChannelName = `private-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;

/**
* @param {Object} pushJSON
Expand Down Expand Up @@ -772,7 +772,7 @@ function subscribeToUserEvents() {
return;
}

const pusherChannelName = `private-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
if (Pusher.isSubscribed(pusherChannelName) || Pusher.isAlreadySubscribing(pusherChannelName)) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function subscribeToUserEvents() {
return;
}

const pusherChannelName = `private-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;

// Live-update an user's preferred locale
Pusher.subscribe(pusherChannelName, Pusher.TYPE.PREFERRED_LOCALE, (pushJSON) => {
Expand Down Expand Up @@ -341,7 +341,7 @@ function subscribeToExpensifyCardUpdates() {
return;
}

const pusherChannelName = `private-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;

// Handle Expensify Card approval flow updates
Pusher.subscribe(pusherChannelName, Pusher.TYPE.EXPENSIFY_CARD_UPDATE, (pushJSON) => {
Expand Down
6 changes: 3 additions & 3 deletions tests/actions/ReportTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
Pusher.unsubscribe(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
});

it('should store a new report action in Onyx when reportComment event is handled via Pusher', () => {
Expand Down Expand Up @@ -104,7 +104,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-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
const channel = Pusher.getChannel(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
channel.emit(Pusher.TYPE.REPORT_COMMENT, {
reportID: REPORT_ID,
reportAction: {...REPORT_ACTION, clientID},
Expand Down Expand Up @@ -158,7 +158,7 @@ describe('actions/Report', () => {
.then(() => {
// We subscribed to the Pusher channel above and now we need to simulate a reportTogglePinned
// Pusher event so we can verify that pinning was handled correctly and merged into the report.
const channel = Pusher.getChannel(`private-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
const channel = Pusher.getChannel(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
channel.emit(Pusher.TYPE.REPORT_TOGGLE_PINNED, {
reportID: REPORT_ID,
isPinned: true,
Expand Down

0 comments on commit d8274f5

Please sign in to comment.