You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
835 B
TypeScript
39 lines
835 B
TypeScript
import { StringUtils } from '../../../../session/utils';
|
|
|
|
import fetch from 'node-fetch';
|
|
|
|
class StubMessageAPI {
|
|
public ourKey: string;
|
|
public baseUrl: string;
|
|
constructor(ourKey: string) {
|
|
this.ourKey = ourKey;
|
|
this.baseUrl = 'http://localhost:3000';
|
|
}
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
public async sendMessage(
|
|
pubKey: string,
|
|
data: any,
|
|
messageTimeStamp: number,
|
|
ttl: number,
|
|
options = {}
|
|
) {
|
|
// console.warn('STUBBED message api ', pubKey, ttl);
|
|
const post = {
|
|
method: 'POST',
|
|
};
|
|
|
|
const data64 = StringUtils.decode(data, 'base64');
|
|
await fetch(
|
|
`${
|
|
this.baseUrl
|
|
}/messages?pubkey=${pubKey}×tamp=${messageTimeStamp}&data=${encodeURIComponent(
|
|
data64
|
|
)}`,
|
|
post
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = StubMessageAPI;
|