move the PN server notify() to not use dot_net_api
parent
6f8c8ee1b3
commit
744be229b7
@ -1,27 +0,0 @@
|
|||||||
/* global dcodeIO */
|
|
||||||
|
|
||||||
const LokiAppDotNetAPI = require('./loki_app_dot_net_api');
|
|
||||||
|
|
||||||
class LokiPushNotificationServerApi {
|
|
||||||
constructor() {
|
|
||||||
this.ourKey = '642a6585919742e5a2d4dc51244964fbcd8bcab2b75612407de58b810740d049';
|
|
||||||
this.serverUrl = 'https://live.apns.getsession.org';
|
|
||||||
this._server = new LokiAppDotNetAPI(this.ourKey, this.serverUrl);
|
|
||||||
|
|
||||||
// make sure pubKey & pubKeyHex are set in _server
|
|
||||||
this.pubKey = this._server.getPubKeyForUrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
async notify(plainTextBuffer, sentTo) {
|
|
||||||
const options = {
|
|
||||||
method: 'post',
|
|
||||||
objBody: {
|
|
||||||
data: dcodeIO.ByteBuffer.wrap(plainTextBuffer).toString('base64'),
|
|
||||||
send_to: sentTo,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return this._server.serverRequest('notify', options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = LokiPushNotificationServerApi;
|
|
@ -0,0 +1,20 @@
|
|||||||
|
import { serverRequest } from '../session/onions/onionSend';
|
||||||
|
import { fromArrayBufferToBase64 } from '../session/utils/String';
|
||||||
|
|
||||||
|
const pnServerPubkeyHex = '642a6585919742e5a2d4dc51244964fbcd8bcab2b75612407de58b810740d049';
|
||||||
|
const pnServerUrl = 'https://live.apns.getsession.org';
|
||||||
|
|
||||||
|
export async function notify(plainTextBuffer: ArrayBuffer, sentTo: string) {
|
||||||
|
const options = {
|
||||||
|
method: 'post',
|
||||||
|
objBody: {
|
||||||
|
data: fromArrayBufferToBase64(plainTextBuffer),
|
||||||
|
send_to: sentTo,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const endpoint = 'notify';
|
||||||
|
return serverRequest(`${pnServerUrl}/${endpoint}`, {
|
||||||
|
...options,
|
||||||
|
srvPubKey: pnServerPubkeyHex,
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
import * as PnServer from './PnServer';
|
||||||
|
|
||||||
|
export { PnServer };
|
Loading…
Reference in New Issue