Move to websocket for requests to signal server
This commit is contained in:
parent
8449f343a6
commit
1c1d0e2da0
31 changed files with 1892 additions and 1336 deletions
|
@ -1,13 +1,12 @@
|
|||
// Copyright 2019-2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { isFunction, isNumber, omit } from 'lodash';
|
||||
import { isNumber, omit } from 'lodash';
|
||||
import { v4 as getGuid } from 'uuid';
|
||||
|
||||
import dataInterface from '../sql/Client';
|
||||
import { downloadAttachment } from '../util/downloadAttachment';
|
||||
import { stringFromBytes } from '../Crypto';
|
||||
import MessageReceiver from '../textsecure/MessageReceiver';
|
||||
import {
|
||||
AttachmentDownloadJobType,
|
||||
AttachmentDownloadJobTypeType,
|
||||
|
@ -42,7 +41,6 @@ const RETRY_BACKOFF: Record<number, number> = {
|
|||
|
||||
let enabled = false;
|
||||
let timeout: NodeJS.Timeout | null;
|
||||
let getMessageReceiver: () => MessageReceiver | undefined;
|
||||
let logger: LoggerType;
|
||||
const _activeAttachmentDownloadJobs: Record<
|
||||
string,
|
||||
|
@ -50,17 +48,11 @@ const _activeAttachmentDownloadJobs: Record<
|
|||
> = {};
|
||||
|
||||
type StartOptionsType = {
|
||||
getMessageReceiver: () => MessageReceiver | undefined;
|
||||
logger: LoggerType;
|
||||
};
|
||||
|
||||
export async function start(options: StartOptionsType): Promise<void> {
|
||||
({ getMessageReceiver, logger } = options);
|
||||
if (!isFunction(getMessageReceiver)) {
|
||||
throw new Error(
|
||||
'attachment_downloads/start: getMessageReceiver must be a function'
|
||||
);
|
||||
}
|
||||
({ logger } = options);
|
||||
if (!logger) {
|
||||
throw new Error('attachment_downloads/start: logger must be provided!');
|
||||
}
|
||||
|
@ -220,11 +212,6 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
|
|||
const pending = true;
|
||||
await setAttachmentDownloadJobPending(id, pending);
|
||||
|
||||
const messageReceiver = getMessageReceiver();
|
||||
if (!messageReceiver) {
|
||||
throw new Error('_runJob: messageReceiver not found');
|
||||
}
|
||||
|
||||
const downloaded = await downloadAttachment(attachment);
|
||||
|
||||
if (!downloaded) {
|
||||
|
|
|
@ -6,17 +6,9 @@
|
|||
import { Collection, Model } from 'backbone';
|
||||
import { MessageModel } from '../models/messages';
|
||||
import { isOutgoing } from '../state/selectors/message';
|
||||
import { ReactionAttributesType } from '../model-types.d';
|
||||
|
||||
type ReactionsAttributesType = {
|
||||
emoji: string;
|
||||
remove: boolean;
|
||||
targetAuthorUuid: string;
|
||||
targetTimestamp: number;
|
||||
timestamp: number;
|
||||
fromId: string;
|
||||
};
|
||||
|
||||
export class ReactionModel extends Model<ReactionsAttributesType> {}
|
||||
export class ReactionModel extends Model<ReactionAttributesType> {}
|
||||
|
||||
let singleton: Reactions | undefined;
|
||||
|
||||
|
@ -63,7 +55,7 @@ export class Reactions extends Collection {
|
|||
|
||||
async onReaction(
|
||||
reaction: ReactionModel
|
||||
): Promise<ReactionModel | undefined> {
|
||||
): Promise<ReactionAttributesType | undefined> {
|
||||
try {
|
||||
// The conversation the target message was in; we have to find it in the database
|
||||
// to to figure that out.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue