Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Pusher to Use Encrypted Channels #8982

Merged
merged 2 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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