mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Linting
This commit is contained in:
parent
e343a04eea
commit
57195017f9
5 changed files with 72 additions and 68 deletions
10
app/sql.js
10
app/sql.js
|
@ -8,7 +8,15 @@ const { remove: removeUserConfig } = require('./user_config');
|
||||||
|
|
||||||
const pify = require('pify');
|
const pify = require('pify');
|
||||||
const uuidv4 = require('uuid/v4');
|
const uuidv4 = require('uuid/v4');
|
||||||
const { map, isString, fromPairs, forEach, last, isEmpty, isObject } = require('lodash');
|
const {
|
||||||
|
map,
|
||||||
|
isString,
|
||||||
|
fromPairs,
|
||||||
|
forEach,
|
||||||
|
last,
|
||||||
|
isEmpty,
|
||||||
|
isObject,
|
||||||
|
} = require('lodash');
|
||||||
|
|
||||||
// To get long stack traces
|
// To get long stack traces
|
||||||
// https://github.com/mapbox/node-sqlite3/wiki/API#sqlite3verbose
|
// https://github.com/mapbox/node-sqlite3/wiki/API#sqlite3verbose
|
||||||
|
|
|
@ -1342,7 +1342,7 @@
|
||||||
|
|
||||||
// Add the message sending on another queue so that our UI doesn't get blocked
|
// Add the message sending on another queue so that our UI doesn't get blocked
|
||||||
this.queueMessageSend(async () => {
|
this.queueMessageSend(async () => {
|
||||||
message.send(this.wrapSend(promise))
|
message.send(this.wrapSend(promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
Contact,
|
Contact,
|
||||||
PhoneNumber,
|
PhoneNumber,
|
||||||
Attachment,
|
Attachment,
|
||||||
Errors
|
Errors,
|
||||||
} = Signal.Types;
|
} = Signal.Types;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -1021,74 +1021,71 @@ MessageReceiver.prototype.extend({
|
||||||
}
|
}
|
||||||
return p.then(() =>
|
return p.then(() =>
|
||||||
this.processDecrypted(envelope, msg).then(async message => {
|
this.processDecrypted(envelope, msg).then(async message => {
|
||||||
const groupId = message.group && message.group.id;
|
const groupId = message.group && message.group.id;
|
||||||
const isBlocked = this.isGroupBlocked(groupId);
|
const isBlocked = this.isGroupBlocked(groupId);
|
||||||
const isMe = envelope.source === textsecure.storage.user.getNumber();
|
const isMe = envelope.source === textsecure.storage.user.getNumber();
|
||||||
const conversation = window.ConversationController.get(
|
const conversation = window.ConversationController.get(envelope.source);
|
||||||
envelope.source
|
const isLeavingGroup = Boolean(
|
||||||
);
|
message.group &&
|
||||||
const isLeavingGroup = Boolean(
|
message.group.type === textsecure.protobuf.GroupContext.Type.QUIT
|
||||||
message.group &&
|
);
|
||||||
message.group.type === textsecure.protobuf.GroupContext.Type.QUIT
|
const friendRequest =
|
||||||
);
|
envelope.type === textsecure.protobuf.Envelope.Type.FRIEND_REQUEST;
|
||||||
const friendRequest =
|
|
||||||
envelope.type === textsecure.protobuf.Envelope.Type.FRIEND_REQUEST;
|
|
||||||
|
|
||||||
// Check if we need to update any profile names
|
// Check if we need to update any profile names
|
||||||
if (!isMe && conversation) {
|
if (!isMe && conversation) {
|
||||||
let profile = null;
|
let profile = null;
|
||||||
if (message.profile) {
|
if (message.profile) {
|
||||||
profile = JSON.parse(message.profile.encodeJSON());
|
profile = JSON.parse(message.profile.encodeJSON());
|
||||||
}
|
|
||||||
|
|
||||||
// Update the conversation
|
|
||||||
await conversation.setProfile(profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (friendRequest && isMe) {
|
// Update the conversation
|
||||||
window.log.info('refusing to add a friend request to ourselves');
|
await conversation.setProfile(profile);
|
||||||
throw new Error('Cannot add a friend request for ourselves!');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groupId && isBlocked && !(isMe && isLeavingGroup)) {
|
|
||||||
window.log.warn(
|
|
||||||
`Message ${this.getEnvelopeId(
|
|
||||||
envelope
|
|
||||||
)} ignored; destined for blocked group`
|
|
||||||
);
|
|
||||||
return this.removeFromCache(envelope);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!message.body) {
|
|
||||||
// Trigger conversation friend request event for empty message
|
|
||||||
if (conversation && !message.flags) {
|
|
||||||
const isFriendRequestAccept = await conversation.onFriendRequestAccepted();
|
|
||||||
if (isFriendRequestAccept) {
|
|
||||||
await conversation.notifyFriendRequest(
|
|
||||||
envelope.source,
|
|
||||||
'accepted'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.removeFromCache(envelope);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ev = new Event('message');
|
|
||||||
ev.confirm = this.removeFromCache.bind(this, envelope);
|
|
||||||
ev.data = {
|
|
||||||
friendRequest,
|
|
||||||
source: envelope.source,
|
|
||||||
sourceDevice: envelope.sourceDevice,
|
|
||||||
timestamp: envelope.timestamp.toNumber(),
|
|
||||||
receivedAt: envelope.receivedAt,
|
|
||||||
unidentifiedDeliveryReceived: envelope.unidentifiedDeliveryReceived,
|
|
||||||
isP2p: envelope.isP2p,
|
|
||||||
message,
|
|
||||||
};
|
|
||||||
return this.dispatchAndWait(ev);
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
if (friendRequest && isMe) {
|
||||||
|
window.log.info('refusing to add a friend request to ourselves');
|
||||||
|
throw new Error('Cannot add a friend request for ourselves!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupId && isBlocked && !(isMe && isLeavingGroup)) {
|
||||||
|
window.log.warn(
|
||||||
|
`Message ${this.getEnvelopeId(
|
||||||
|
envelope
|
||||||
|
)} ignored; destined for blocked group`
|
||||||
|
);
|
||||||
|
return this.removeFromCache(envelope);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message.body) {
|
||||||
|
// Trigger conversation friend request event for empty message
|
||||||
|
if (conversation && !message.flags) {
|
||||||
|
const isFriendRequestAccept = await conversation.onFriendRequestAccepted();
|
||||||
|
if (isFriendRequestAccept) {
|
||||||
|
await conversation.notifyFriendRequest(
|
||||||
|
envelope.source,
|
||||||
|
'accepted'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.removeFromCache(envelope);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ev = new Event('message');
|
||||||
|
ev.confirm = this.removeFromCache.bind(this, envelope);
|
||||||
|
ev.data = {
|
||||||
|
friendRequest,
|
||||||
|
source: envelope.source,
|
||||||
|
sourceDevice: envelope.sourceDevice,
|
||||||
|
timestamp: envelope.timestamp.toNumber(),
|
||||||
|
receivedAt: envelope.receivedAt,
|
||||||
|
unidentifiedDeliveryReceived: envelope.unidentifiedDeliveryReceived,
|
||||||
|
isP2p: envelope.isP2p,
|
||||||
|
message,
|
||||||
|
};
|
||||||
|
return this.dispatchAndWait(ev);
|
||||||
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
handleLegacyMessage(envelope) {
|
handleLegacyMessage(envelope) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ interface Props {
|
||||||
showFriendRequestIndicator?: boolean;
|
showFriendRequestIndicator?: boolean;
|
||||||
isBlocked: boolean;
|
isBlocked: boolean;
|
||||||
isOnline: boolean;
|
isOnline: boolean;
|
||||||
isMe: boolean;
|
|
||||||
hasNickname: boolean;
|
hasNickname: boolean;
|
||||||
|
|
||||||
i18n: Localizer;
|
i18n: Localizer;
|
||||||
|
|
Loading…
Reference in a new issue