Skip to content

Commit

Permalink
Merge branch 'master' into configure-load-message-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi authored Aug 17, 2022
2 parents c12b0ff + a516cc1 commit 4e0cd33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,12 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
}
*/
async updateAppSettings(options: AppSettings) {
if (options.apn_config?.p12_cert) {
options.apn_config.p12_cert = Buffer.from(options.apn_config.p12_cert).toString('base64');
const apn_config = options.apn_config;
if (apn_config?.p12_cert) {
options = {
...options,
apn_config: { ...apn_config, p12_cert: Buffer.from(apn_config.p12_cert).toString('base64') },
};
}
return await this.patch<APIResponse>(this.baseURL + '/app', options);
}
Expand Down
9 changes: 9 additions & 0 deletions test/unit/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ describe('StreamChat getInstance', () => {

expect(client.baseURL).to.equal(baseURL);
});

it('app settings do not mutate', async () => {
const client = new StreamChat('key', 'secret');
const cert = Buffer.from('test');
const options = { apn_config: { p12_cert: cert } };
await expect(client.updateAppSettings(options)).to.be.rejectedWith(/.*/);

expect(options.apn_config.p12_cert).to.be.eql(cert);
});
});

describe('Client userMuteStatus', function () {
Expand Down

0 comments on commit 4e0cd33

Please sign in to comment.