rename a few loki to session

This commit is contained in:
Audric Ackermann 2022-02-18 13:03:47 +11:00
parent d66716df2c
commit 3fed22048b
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4
28 changed files with 98 additions and 181 deletions

View File

@ -1,5 +1,4 @@
{
"privacyPolicy": "Terms & Privacy Policy",
"copyErrorAndQuit": "Copy error and quit",
"unknown": "Unknown",
"databaseError": "Database Error",
@ -17,7 +16,6 @@
"editMenuCut": "Cut",
"editMenuCopy": "Copy",
"editMenuPaste": "Paste",
"editMenuPasteAndMatchStyle": "Paste and Match Style",
"editMenuDelete": "Delete",
"editMenuDeleteContact": "Delete Contact",
"editMenuDeleteGroup": "Delete Group",
@ -25,7 +23,6 @@
"windowMenuClose": "Close Window",
"windowMenuMinimize": "Minimize",
"windowMenuZoom": "Zoom",
"windowMenuBringAllToFront": "Bring All to Front",
"viewMenuResetZoom": "Actual Size",
"viewMenuZoomIn": "Zoom In",
"viewMenuZoomOut": "Zoom Out",

View File

@ -7,7 +7,6 @@ let environment;
// In production mode, NODE_ENV cannot be customized by the user
if (isDevelopment) {
environment = process.env.NODE_ENV || 'development';
process.env.LOKI_DEV = 1;
} else {
environment = 'production';
}

View File

@ -54,10 +54,6 @@ exports.createTemplate = (options, messages) => {
role: 'paste',
label: messages.editMenuPaste,
},
{
role: 'pasteandmatchstyle',
label: messages.editMenuPasteAndMatchStyle,
},
{
role: 'delete',
label: messages.editMenuDelete,
@ -242,13 +238,6 @@ function updateForMac(template, messages, options) {
label: messages.show,
click: showWindow,
},
{
type: 'separator',
},
{
role: 'front',
label: messages.windowMenuBringAllToFront,
},
];
return template;

View File

@ -65,13 +65,6 @@ exports.setup = (browserWindow, messages) => {
template.push({ label: messages.editMenuPaste, role: 'paste' });
}
if (editFlags.canPaste) {
template.push({
label: messages.editMenuPasteAndMatchStyle,
role: 'pasteAndMatchStyle',
});
}
// Only enable select all in editors because select all in non-editors
// results in all the UI being selected
if (editFlags.canSelectAll && params.isEditable) {

View File

@ -1,7 +1,8 @@
<html>
<head>
<meta http-equiv="Content-Security-Policy"
content="default-src 'none';
<head>
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
child-src 'self';
connect-src 'self' https: wss:;
font-src 'self';
@ -12,42 +13,40 @@
object-src 'none';
script-src 'self';
style-src 'self' 'unsafe-inline';"
>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style>
</style>
</head>
<body class='debug-log-window'>
</body>
<script type='text/x-tmpl-mustache' id='debug-log'>
<div class='content'>
<div>
<a class='x close' alt='close debug log' href='#'></a>
<h1> {{ title }} </h1>
<p> {{ debugLogExplanation }}</p>
/>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style></style>
</head>
<body class="debug-log-window"></body>
<script type="text/x-tmpl-mustache" id="debug-log">
<div class='content'>
<div>
<a class='x close' alt='close debug log' href='#'></a>
<h1> {{ title }} </h1>
<p> {{ debugLogExplanation }}</p>
</div>
<textarea spellcheck='false' rows='5'></textarea>
<div class='buttons'>
<button class='grey submit'>{{ submit }}</button>
</div>
<div class='result'>
</div>
</div>
<textarea spellcheck='false' rows='5'></textarea>
<div class='buttons'>
<button class='grey submit'>{{ submit }}</button>
</script>
<script type="text/x-tmpl-mustache" id="debug-log-link">
<div class='input-group clearfix'>
<input type='text' class='link' readonly value='{{ url }}' />
<a class='open' alt='open in a new browser tab' target='_blank' href='{{ url }}'></a>
</div>
<div class='result'>
</div>
</div>
</script>
<script type='text/x-tmpl-mustache' id='debug-log-link'>
<div class='input-group clearfix'>
<input type='text' class='link' readonly value='{{ url }}' />
<a class='open' alt='open in a new browser tab' target='_blank' href='{{ url }}'></a>
</div>
<p>
<a class='report-link' target='_blank'
href='https://github.com/loki-project/session-desktop/issues/new/'>
{{ reportIssue }}
</a>
</p>
</script>
<script type='text/javascript' src='js/components.js'></script>
<script type='text/javascript' src='js/views/whisper_view.js'></script>
<script type='text/javascript' src='js/views/debug_log_view.js'></script>
<script type='text/javascript' src='js/debug_log_start.js'></script>
<p>
<a class='report-link' target='_blank'
href='https://github.com/oxen-io/session-desktop/issues/new/'>
{{ reportIssue }}
</a>
</p>
</script>
<script type="text/javascript" src="js/components.js"></script>
<script type="text/javascript" src="js/views/whisper_view.js"></script>
<script type="text/javascript" src="js/views/debug_log_view.js"></script>
<script type="text/javascript" src="js/debug_log_start.js"></script>
</html>

View File

@ -1,4 +1,4 @@
set -e
find release/linux -type d | xargs chmod 755
find release/linux -type f | xargs chmod 644
chmod +x release/linux/loki-messenger*
chmod +x release/linux/session-desktop*

View File

@ -19,9 +19,6 @@ const { SessionInboxView } = require('../../ts/components/SessionInboxView');
// Types
const SettingsType = require('../../ts/types/Settings');
// Views
const Initialization = require('./views/initialization');
exports.setup = () => {
Data.init();
@ -35,10 +32,6 @@ exports.setup = () => {
Settings: SettingsType,
};
const Views = {
Initialization,
};
return {
Components,
Crypto,
@ -49,6 +42,5 @@ exports.setup = () => {
Settings,
Types,
Util,
Views,
};
};

View File

@ -1,47 +0,0 @@
/* eslint-env browser */
/* global i18n: false */
const DISPLAY_THRESHOLD = 3000; // milliseconds
const SELECTOR = '.app-loading-screen .message';
let timeout;
let targetString;
let didTimeout = false;
const clear = () => {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
};
const setMessage = loadingText => {
const message = document.querySelector(SELECTOR);
if (!message) {
return clear;
}
targetString = loadingText || i18n('optimizingApplication');
message.innerText = didTimeout ? targetString : i18n('loading');
if (timeout) {
return clear;
}
timeout = setTimeout(() => {
didTimeout = true;
const innerMessage = document.querySelector(SELECTOR);
if (!innerMessage) {
return;
}
innerMessage.innerText = targetString;
}, DISPLAY_THRESHOLD);
return clear;
};
module.exports = {
setMessage,
};

View File

@ -28,7 +28,7 @@ const {
systemPreferences,
} = electron;
// FIXME Hardcoding appId to prevent build failrues on release.
// FIXME Hardcoding appId to prevent build failures on release.
// const appUserModelId = packageJson.build.appId;
const appUserModelId = 'com.loki-project.messenger-desktop';
console.log('Set Windows Application User Model ID (AUMID)', {
@ -986,7 +986,7 @@ ipc.on('set-call-media-permissions', (event, value) => {
event.sender.send('set-success-call-media-permissions', null);
});
// Loki - Auto updating
// Session - Auto updating
ipc.on('get-auto-update-setting', event => {
const configValue = userConfig.get('autoUpdate');
// eslint-disable-next-line no-param-reassign

View File

@ -28,7 +28,7 @@ window.isDev = () => config.environment === 'development';
window.getCommitHash = () => config.commitHash;
window.getNodeVersion = () => config.node_version;
window.lokiFeatureFlags = {
window.sessionFeatureFlags = {
useOnionRequests: true,
useMessageRequests: false,
useCallMessage: true,

View File

@ -214,7 +214,7 @@ const CallButton = () => {
isMe ||
!selectedConvoKey ||
isBlocked ||
!window.lokiFeatureFlags.useCallMessage
!window.sessionFeatureFlags.useCallMessage
) {
return null;
}

View File

@ -110,7 +110,7 @@ export class LeftPaneMessageSection extends React.Component<Props> {
return (
<div className="module-conversations-list-content">
<SessionSearchInput />
{window.lokiFeatureFlags.useMessageRequests ? (
{window.sessionFeatureFlags.useMessageRequests ? (
<MessageRequestsBanner
handleOnClick={() => {
window.inboxStore?.dispatch(setOverlayMode('message-requests'));

View File

@ -21,7 +21,7 @@ import useKey from 'react-use/lib/useKey';
*/
async function handleBlockAllRequestsClick(messageRequestSetting: boolean) {
const messageRequestsEnabled =
messageRequestSetting && window?.lokiFeatureFlags?.useMessageRequests;
messageRequestSetting && window?.sessionFeatureFlags?.useMessageRequests;
if (!messageRequestsEnabled) {
return;

View File

@ -57,7 +57,7 @@ export const SettingsCategoryPrivacy = (props: {
const forceUpdate = useUpdate();
const dispatch = useDispatch();
const hasMessageRequestFlag = window.lokiFeatureFlags.useMessageRequests;
const hasMessageRequestFlag = window.sessionFeatureFlags.useMessageRequests;
if (props.hasPassword !== null) {
return (
@ -71,7 +71,7 @@ export const SettingsCategoryPrivacy = (props: {
description={window.i18n('mediaPermissionsDescription')}
active={Boolean(window.getSettingValue('media-permissions'))}
/>
{window.lokiFeatureFlags.useCallMessage && (
{window.sessionFeatureFlags.useCallMessage && (
<SessionToggleWithDescription
onClickToggle={async () => {
await toggleCallMediaPermissions(forceUpdate);

View File

@ -1438,7 +1438,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
if (
isMe &&
window.lokiFeatureFlags.useMessageRequests &&
window.sessionFeatureFlags.useMessageRequests &&
window.inboxStore?.getState().userConfig.messageRequests
) {
await this.setIsApproved(true);
@ -1491,7 +1491,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
return false;
}
const msgRequestsEnabled =
window.lokiFeatureFlags.useMessageRequests &&
window.sessionFeatureFlags.useMessageRequests &&
window.inboxStore?.getState().userConfig.messageRequests;
// if msg requests are unused, we have to send typing (this is already a private active unblocked convo)

View File

@ -141,7 +141,7 @@ const handleContactReceived = async (
}
if (
window.lokiFeatureFlags.useMessageRequests &&
window.sessionFeatureFlags.useMessageRequests &&
window.inboxStore?.getState().userConfig.messageRequests
) {
if (contactReceived.isApproved) {

View File

@ -428,7 +428,7 @@ export async function innerHandleSwarmContentMessage(
if (content.unsendMessage) {
await handleUnsendMessage(envelope, content.unsendMessage as SignalService.Unsend);
}
if (content.callMessage && window.lokiFeatureFlags?.useCallMessage) {
if (content.callMessage && window.sessionFeatureFlags?.useCallMessage) {
await handleCallMessage(envelope, content.callMessage as SignalService.CallMessage);
}
} catch (e) {

View File

@ -253,7 +253,7 @@ async function handleRegularMessage(
if (type === 'outgoing') {
await handleSyncedReceipts(message, conversation);
if (window.lokiFeatureFlags.useMessageRequests) {
if (window.sessionFeatureFlags.useMessageRequests) {
// assumes sync receipts are always from linked device outgoings
await conversation.setIsApproved(true);
}

View File

@ -48,7 +48,7 @@ export async function fetchSnodePoolFromSeedNodeWithRetries(
return fetchSnodePool;
} catch (e) {
window?.log?.warn(
'LokiSnodeAPI::fetchSnodePoolFromSeedNodeWithRetries - error',
'SessionSnodeAPI::fetchSnodePoolFromSeedNodeWithRetries - error',
e.code,
e.message
);

View File

@ -1,4 +1,4 @@
import { snodeRpc } from './lokiRpc';
import { snodeRpc } from './sessionRpc';
import {
getRandomSnode,
@ -86,7 +86,7 @@ async function requestSnodesForPubkeyWithTargetNodeRetryable(
});
if (!result) {
window?.log?.warn(
`LokiSnodeAPI::requestSnodesForPubkeyWithTargetNodeRetryable - lokiRpc on ${targetNode.ip}:${targetNode.port} returned falsish value`,
`SessionSnodeAPI::requestSnodesForPubkeyWithTargetNodeRetryable - sessionRpc on ${targetNode.ip}:${targetNode.port} returned falsish value`,
result
);
throw new Error('requestSnodesForPubkeyWithTargetNodeRetryable: Invalid result');
@ -103,7 +103,7 @@ async function requestSnodesForPubkeyWithTargetNodeRetryable(
if (!json.snodes) {
// we hit this when snode gives 500s
window?.log?.warn(
`LokiSnodeAPI::requestSnodesForPubkeyRetryable - lokiRpc on ${targetNode.ip}:${targetNode.port} returned falsish value for snodes`,
`SessionSnodeAPI::requestSnodesForPubkeyRetryable - sessionRpc on ${targetNode.ip}:${targetNode.port} returned falsish value for snodes`,
result
);
throw new Error('Invalid json (empty)');
@ -176,7 +176,7 @@ export async function requestSnodesForPubkey(pubKey: string): Promise<Array<Snod
// if all retry fails, we will end up in the catch below when the last exception thrown
return await requestSnodesForPubkeyRetryable(pubKey);
} catch (e) {
window?.log?.error('LokiSnodeAPI::requestSnodesForPubkey - error', e);
window?.log?.error('SessionSnodeAPI::requestSnodesForPubkey - error', e);
return [];
}
@ -393,10 +393,7 @@ export async function TEST_getSnodePoolFromSnode(targetNode: Snode): Promise<Arr
const json = JSON.parse(result.body);
if (!json || !json.result || !json.result.service_node_states?.length) {
window?.log?.error(
'loki_snode_api:::getSnodePoolFromSnode - invalid result from snode',
result.body
);
window?.log?.error('getSnodePoolFromSnode - invalid result from snode', result.body);
return [];
}
@ -452,11 +449,7 @@ export async function storeOnNode(
}
return false;
} catch (e) {
window?.log?.warn(
'loki_message:::store - send error:',
e,
`destination ${targetNode.ip}:${targetNode.port}`
);
window?.log?.warn('store - send error:', e, `destination ${targetNode.ip}:${targetNode.port}`);
throw e;
}
}
@ -484,17 +477,17 @@ export async function retrieveNextMessages(
if (!result) {
window?.log?.warn(
`loki_message:::_retrieveNextMessages - lokiRpc could not talk to ${targetNode.ip}:${targetNode.port}`
`_retrieveNextMessages - sessionRpc could not talk to ${targetNode.ip}:${targetNode.port}`
);
throw new Error(
`loki_message:::_retrieveNextMessages - lokiRpc could not talk to ${targetNode.ip}:${targetNode.port}`
`_retrieveNextMessages - sessionRpc could not talk to ${targetNode.ip}:${targetNode.port}`
);
}
if (result.status !== 200) {
window?.log?.warn('retrieve result is not 200');
throw new Error(
`loki_message:::_retrieveNextMessages - retrieve result is not 200 with ${targetNode.ip}:${targetNode.port}`
`_retrieveNextMessages - retrieve result is not 200 with ${targetNode.ip}:${targetNode.port}`
);
}
@ -513,7 +506,7 @@ export async function retrieveNextMessages(
window.inboxStore?.dispatch(updateIsOnline(true));
}
throw new Error(
`loki_message:::_retrieveNextMessages - exception while parsing json of nextMessage ${targetNode.ip}:${targetNode.port}: ${e?.message}`
`_retrieveNextMessages - exception while parsing json of nextMessage ${targetNode.ip}:${targetNode.port}: ${e?.message}`
);
}
}

View File

@ -439,7 +439,7 @@ export async function processOnionResponse({
if (!ciphertext) {
window?.log?.warn(
'[path] lokiRpc::processingOnionResponse - Target node return empty ciphertext'
'[path] sessionRpc::processingOnionResponse - Target node return empty ciphertext'
);
throw new Error('Target node return empty ciphertext');
}
@ -453,16 +453,16 @@ export async function processOnionResponse({
plaintext = decoded.plaintext;
ciphertextBuffer = decoded.ciphertextBuffer;
} catch (e) {
window?.log?.error('[path] lokiRpc::processingOnionResponse - decode error', e);
window?.log?.error('[path] sessionRpc::processingOnionResponse - decode error', e);
if (symmetricKey) {
window?.log?.error(
'[path] lokiRpc::processingOnionResponse - symmetricKey',
'[path] sessionRpc::processingOnionResponse - symmetricKey',
toHex(symmetricKey)
);
}
if (ciphertextBuffer) {
window?.log?.error(
'[path] lokiRpc::processingOnionResponse - ciphertextBuffer',
'[path] sessionRpc::processingOnionResponse - ciphertextBuffer',
toHex(ciphertextBuffer)
);
}
@ -470,7 +470,7 @@ export async function processOnionResponse({
}
if (debug) {
window?.log?.debug('lokiRpc::processingOnionResponse - plaintext', plaintext);
window?.log?.debug('sessionRpc::processingOnionResponse - plaintext', plaintext);
}
try {
@ -491,7 +491,9 @@ export async function processOnionResponse({
return jsonRes as SnodeResponse;
} catch (e) {
window?.log?.error(`[path] lokiRpc::processingOnionResponse - Rethrowing error ${e.message}'`);
window?.log?.error(
`[path] sessionRpc::processingOnionResponse - Rethrowing error ${e.message}'`
);
throw e;
}
}

View File

@ -45,9 +45,9 @@ async function lokiFetch({
// Absence of targetNode indicates that we want a direct connection
// (e.g. to connect to a seed node for the first time)
const useOnionRequests =
window.lokiFeatureFlags?.useOnionRequests === undefined
window.sessionFeatureFlags?.useOnionRequests === undefined
? true
: window.lokiFeatureFlags?.useOnionRequests;
: window.sessionFeatureFlags?.useOnionRequests;
if (useOnionRequests && targetNode) {
const fetchResult = await lokiOnionFetch({
targetNode,

View File

@ -183,7 +183,7 @@ export async function TEST_fetchFromSeedWithRetriesAndWriteToDb() {
if (!seedNodes || !seedNodes.length) {
window?.log?.error(
'LokiSnodeAPI:::fetchFromSeedWithRetriesAndWriteToDb - getSeedNodeList has not been loaded yet'
'SessionSnodeAPI:::fetchFromSeedWithRetriesAndWriteToDb - getSeedNodeList has not been loaded yet'
);
return;
@ -196,7 +196,7 @@ export async function TEST_fetchFromSeedWithRetriesAndWriteToDb() {
Onions.resetSnodeFailureCount();
} catch (e) {
window?.log?.error(
'LokiSnodeAPI:::fetchFromSeedWithRetriesAndWriteToDb - Failed to fetch snode poll from seed node with retries. Error:',
'SessionSnodeAPI:::fetchFromSeedWithRetriesAndWriteToDb - Failed to fetch snode poll from seed node with retries. Error:',
e
);
}

View File

@ -420,7 +420,7 @@ export async function getGuardNodeOrSelectNewOnes() {
if (guardNodesFromDb.length === 0) {
window?.log?.warn(
'LokiSnodeAPI::getGuardNodeOrSelectNewOnes - no guard nodes in DB. Will be selecting new guards nodes...'
'SessionSnodeAPI::getGuardNodeOrSelectNewOnes - no guard nodes in DB. Will be selecting new guards nodes...'
);
} else {
const allNodes = await SnodePool.getSnodePoolFromDBOrFetchFromSeed();
@ -429,7 +429,7 @@ export async function getGuardNodeOrSelectNewOnes() {
guardNodes = allNodes.filter(x => edKeys.indexOf(x.pubkey_ed25519) !== -1);
if (guardNodes.length < edKeys.length) {
window?.log?.warn(
`LokiSnodeAPI::getGuardNodeOrSelectNewOnes - could not find some guard nodes: ${guardNodes.length}/${edKeys.length} left`
`SessionSnodeAPI::getGuardNodeOrSelectNewOnes - could not find some guard nodes: ${guardNodes.length}/${edKeys.length} left`
);
}
}
@ -444,7 +444,7 @@ export async function getGuardNodeOrSelectNewOnes() {
async function buildNewOnionPathsWorker() {
return pRetry(
async () => {
window?.log?.info('LokiSnodeAPI::buildNewOnionPaths - building new onion paths...');
window?.log?.info('SessionSnodeAPI::buildNewOnionPaths - building new onion paths...');
// get an up to date list of snodes from cache, from db, or from the a seed node.
let allNodes = await SnodePool.getSnodePoolFromDBOrFetchFromSeed();
@ -459,7 +459,9 @@ async function buildNewOnionPathsWorker() {
// be sure to fetch again as that list might have been refreshed by selectGuardNodes
allNodes = await SnodePool.getSnodePoolFromDBOrFetchFromSeed();
window?.log?.info(`LokiSnodeAPI::buildNewOnionPaths, snodePool length: ${allNodes.length}`);
window?.log?.info(
`SessionSnodeAPI::buildNewOnionPaths, snodePool length: ${allNodes.length}`
);
// get all snodes minus the selected guardNodes
if (allNodes.length <= SnodePool.minSnodePoolCount) {
throw new Error('Too few nodes to build an onion path. Even after fetching from seed.');

View File

@ -334,7 +334,7 @@ export const _getLeftPaneLists = (
let unreadCount = 0;
for (const conversation of sortedConversations) {
const excludeUnapproved =
isMessageRequestEnabled && window.lokiFeatureFlags?.useMessageRequests;
isMessageRequestEnabled && window.sessionFeatureFlags?.useMessageRequests;
if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
directConversations.push(conversation);
@ -422,7 +422,7 @@ const _getConversationRequests = (
isMessageRequestEnabled?: boolean
): Array<ReduxConversationType> => {
const pushToMessageRequests =
isMessageRequestEnabled && window?.lokiFeatureFlags?.useMessageRequests;
isMessageRequestEnabled && window?.sessionFeatureFlags?.useMessageRequests;
return _.filter(sortedConversations, conversation => {
return pushToMessageRequests && !conversation.isApproved && !conversation.isBlocked;
});
@ -439,7 +439,7 @@ const _getPrivateContactsPubkeys = (
isMessageRequestEnabled?: boolean
): Array<string> => {
const pushToMessageRequests =
(isMessageRequestEnabled && window?.lokiFeatureFlags?.useMessageRequests) ||
(isMessageRequestEnabled && window?.sessionFeatureFlags?.useMessageRequests) ||
!isMessageRequestEnabled;
return _.filter(sortedConversations, conversation => {

View File

@ -28,11 +28,11 @@ describe('MessageSender', () => {
// tslint:disable-next-line: max-func-body-length
describe('send', () => {
const ourNumber = '0123456789abcdef';
let lokiMessageAPISendStub: sinon.SinonStub<any>;
let sessionMessageAPISendStub: sinon.SinonStub<any>;
let encryptStub: sinon.SinonStub<[PubKey, Uint8Array, EncryptionType]>;
beforeEach(() => {
lokiMessageAPISendStub = sandbox.stub(MessageSender, 'TEST_sendMessageToSnode').resolves();
sessionMessageAPISendStub = sandbox.stub(MessageSender, 'TEST_sendMessageToSnode').resolves();
sandbox.stub(Data, 'getMessageById').resolves();
@ -58,29 +58,29 @@ describe('MessageSender', () => {
encryptStub.throws(new Error('Failed to encrypt.'));
const promise = MessageSender.send(rawMessage, 3, 10);
await expect(promise).is.rejectedWith('Failed to encrypt.');
expect(lokiMessageAPISendStub.callCount).to.equal(0);
expect(sessionMessageAPISendStub.callCount).to.equal(0);
});
it('should only call lokiMessageAPI once if no errors occured', async () => {
await MessageSender.send(rawMessage, 3, 10);
expect(lokiMessageAPISendStub.callCount).to.equal(1);
expect(sessionMessageAPISendStub.callCount).to.equal(1);
});
it('should only retry the specified amount of times before throwing', async () => {
// const clock = sinon.useFakeTimers();
lokiMessageAPISendStub.throws(new Error('API error'));
sessionMessageAPISendStub.throws(new Error('API error'));
const attempts = 2;
const promise = MessageSender.send(rawMessage, attempts, 10);
await expect(promise).is.rejectedWith('API error');
// clock.restore();
expect(lokiMessageAPISendStub.callCount).to.equal(attempts);
expect(sessionMessageAPISendStub.callCount).to.equal(attempts);
});
it('should not throw error if successful send occurs within the retry limit', async () => {
lokiMessageAPISendStub.onFirstCall().throws(new Error('API error'));
sessionMessageAPISendStub.onFirstCall().throws(new Error('API error'));
await MessageSender.send(rawMessage, 3, 10);
expect(lokiMessageAPISendStub.callCount).to.equal(2);
expect(sessionMessageAPISendStub.callCount).to.equal(2);
});
});
@ -102,7 +102,7 @@ describe('MessageSender', () => {
await MessageSender.send(rawMessage, 3, 10);
const args = lokiMessageAPISendStub.getCall(0).args;
const args = sessionMessageAPISendStub.getCall(0).args;
expect(args[0]).to.equal(device.key);
// expect(args[3]).to.equal(visibleMessage.timestamp); the timestamp is overwritten on sending by the network clock offset
expect(args[2]).to.equal(visibleMessage.ttl());
@ -120,7 +120,7 @@ describe('MessageSender', () => {
sandbox.stub(SNodeAPI, 'getLatestTimestampOffset').returns(offset);
await MessageSender.send(rawMessage, 3, 10);
const data = lokiMessageAPISendStub.getCall(0).args[1];
const data = sessionMessageAPISendStub.getCall(0).args[1];
const webSocketMessage = SignalService.WebSocketMessage.decode(data);
expect(webSocketMessage.request?.body).to.not.equal(
undefined,
@ -163,7 +163,7 @@ describe('MessageSender', () => {
const rawMessage = await MessageUtils.toRawMessage(device, visibleMessage);
await MessageSender.send(rawMessage, 3, 10);
const data = lokiMessageAPISendStub.getCall(0).args[1];
const data = sessionMessageAPISendStub.getCall(0).args[1];
const webSocketMessage = SignalService.WebSocketMessage.decode(data);
expect(webSocketMessage.request?.body).to.not.equal(
undefined,

View File

@ -18,7 +18,6 @@ export type LocalizerKeys =
| 'noContactsForGroup'
| 'originalMessageNotAvailable'
| 'linkVisitWarningMessage'
| 'editMenuPasteAndMatchStyle'
| 'anonymous'
| 'viewMenuZoomOut'
| 'dialogClearAllDataDeletionFailedDesc'
@ -236,7 +235,6 @@ export type LocalizerKeys =
| 'audioPermissionNeeded'
| 'timestamp_h'
| 'add'
| 'windowMenuBringAllToFront'
| 'messageRequests'
| 'show'
| 'cannotMixImageAndNonImageAttachments'

6
ts/window.d.ts vendored
View File

@ -20,7 +20,7 @@ declare global {
CONSTANTS: any;
Events: any;
Lodash: any;
LokiSnodeAPI: any;
SessionSnodeAPI: any;
Session: any;
Signal: SignalInterface;
StubAppDotNetApi: any;
@ -36,12 +36,12 @@ declare global {
i18n: LocalizerType;
libsignal: LibsignalProtocol;
log: any;
lokiFeatureFlags: {
sessionFeatureFlags: {
useOnionRequests: boolean;
useMessageRequests: boolean;
useCallMessage: boolean;
};
lokiSnodeAPI: LokiSnodeAPI;
SessionSnodeAPI: SessionSnodeAPI;
onLogin: any;
persistStore?: Persistor;
restart: any;