Merge branch 'clearnet' into sender-keys

pull/1117/head
Ryan Tharp 5 years ago committed by GitHub
commit ead2f62b6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,20 +6,16 @@
"defaultPoWDifficulty": "1", "defaultPoWDifficulty": "1",
"seedNodeList": [ "seedNodeList": [
{ {
"ip": "public.loki.foundation", "ip_url": "http://116.203.53.213/",
"port": "22023" "url": "https://storage.seed1.loki.network/"
}, },
{ {
"ip": "storage.seed1.loki.network", "ip_url": "http://212.199.114.66/",
"port": "22023" "url": "https://storage.seed3.loki.network/"
}, },
{ {
"ip": "storage.seed2.loki.network", "ip_url": "http://144.76.164.202/",
"port": "38157" "url": "https://public.loki.foundation/"
},
{
"ip": "imaginary.stream",
"port": "38157"
} }
], ],
"updatesEnabled": false, "updatesEnabled": false,

@ -1,8 +1,8 @@
{ {
"seedNodeList": [ "seedNodeList": [
{ {
"ip": "public.loki.foundation", "url": "http://public.loki.foundation:38157/",
"port": "38157" "ip_url": "http://144.76.164.202:38157/"
} }
], ],
"openDevTools": true, "openDevTools": true,

@ -1,8 +1,8 @@
{ {
"seedNodeList": [ "seedNodeList": [
{ {
"ip": "127.0.0.1", "ip_url": "http://127.0.0.1:22129/",
"port": "22129" "url": "http://localhost:22129/"
} }
], ],
"openDevTools": true, "openDevTools": true,

@ -1418,6 +1418,11 @@
}); });
Whisper.events.on('deviceUnpairingRequested', async (pubKey, callback) => { Whisper.events.on('deviceUnpairingRequested', async (pubKey, callback) => {
const isSecondaryDevice = !!textsecure.storage.get('isSecondaryDevice');
if (isSecondaryDevice) {
return;
}
await libloki.storage.removePairingAuthorisationForSecondaryPubKey( await libloki.storage.removePairingAuthorisationForSecondaryPubKey(
pubKey pubKey
); );

@ -607,6 +607,7 @@
hasSentFriendRequest: this.hasSentFriendRequest(), hasSentFriendRequest: this.hasSentFriendRequest(),
isBlocked: this.isBlocked(), isBlocked: this.isBlocked(),
isSecondary: !!this.get('secondaryStatus'), isSecondary: !!this.get('secondaryStatus'),
primaryDevice: this.getPrimaryDevicePubKey(),
phoneNumber: format(this.id, { phoneNumber: format(this.id, {
ourRegionCode: regionCode, ourRegionCode: regionCode,
}), }),

@ -1,5 +1,5 @@
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
/* global window, textsecure, ConversationController, _, log, process, Buffer, StringView, dcodeIO */ /* global window, textsecure, ConversationController, _, log, process, Buffer, StringView, dcodeIO, URL */
const { lokiRpc } = require('./loki_rpc'); const { lokiRpc } = require('./loki_rpc');
// not sure I like this name but it's been than util // not sure I like this name but it's been than util
@ -44,22 +44,33 @@ async function tryGetSnodeListFromLokidSeednode(
)[0]; )[0];
let snodes = []; let snodes = [];
try { try {
const getSnodesFromSeedUrl = async urlObj => {
const response = await lokiRpc( const response = await lokiRpc(
`http://${seedNode.ip}`, `${urlObj.protocol}//${urlObj.hostname}`,
seedNode.port, urlObj.port,
'get_n_service_nodes', 'get_n_service_nodes',
params, params,
{}, // Options {}, // Options
'/json_rpc' // Seed request endpoint '/json_rpc' // Seed request endpoint
); );
// Filter 0.0.0.0 nodes which haven't submitted uptime proofs // Filter 0.0.0.0 nodes which haven't submitted uptime proofs
snodes = response.result.service_node_states.filter( return response.result.service_node_states.filter(
snode => snode.public_ip !== '0.0.0.0' snode => snode.public_ip !== '0.0.0.0'
); );
};
const tryUrl = new URL(seedNode.url);
snodes = getSnodesFromSeedUrl(tryUrl);
// throw before clearing the lock, so the retries can kick in // throw before clearing the lock, so the retries can kick in
if (snodes.length === 0) {
// fall back on ip_url
const tryIpUrl = new URL(seedNode.ip_url);
snodes = getSnodesFromSeedUrl(tryIpUrl);
if (snodes.length === 0) { if (snodes.length === 0) {
// does this error message need to be exactly this? // does this error message need to be exactly this?
throw new window.textsecure.SeedNodeError('Failed to contact seed node'); throw new window.textsecure.SeedNodeError(
'Failed to contact seed node'
);
}
} }
return snodes; return snodes;
} catch (e) { } catch (e) {

@ -1429,7 +1429,12 @@ MessageReceiver.prototype.extend({
); );
return this.removeFromCache(envelope); return this.removeFromCache(envelope);
} }
if (!friendRequest && this.isMessageEmpty(message)) {
window.log.warn(
`Message ${this.getEnvelopeId(envelope)} ignored; it was empty`
);
return this.removeFromCache(envelope);
}
const ev = new Event('message'); const ev = new Event('message');
ev.confirm = this.removeFromCache.bind(this, envelope); ev.confirm = this.removeFromCache.bind(this, envelope);
ev.data = { ev.data = {
@ -1443,6 +1448,27 @@ MessageReceiver.prototype.extend({
}; };
return this.dispatchAndWait(ev); return this.dispatchAndWait(ev);
}, },
isMessageEmpty({
body,
attachments,
group,
flags,
quote,
contact,
preview,
groupInvitation,
}) {
return (
!flags &&
_.isEmpty(body) &&
_.isEmpty(attachments) &&
_.isEmpty(group) &&
_.isEmpty(quote) &&
_.isEmpty(contact) &&
_.isEmpty(preview) &&
_.isEmpty(groupInvitation)
);
},
handleLegacyMessage(envelope) { handleLegacyMessage(envelope) {
return this.decrypt(envelope, envelope.legacyMessage).then(plaintext => { return this.decrypt(envelope, envelope.legacyMessage).then(plaintext => {
if (!plaintext) { if (!plaintext) {

@ -175,6 +175,7 @@ function prepareURL(pathSegments, moreKeys) {
localUrl: config.get('localUrl'), localUrl: config.get('localUrl'),
cdnUrl: config.get('cdnUrl'), cdnUrl: config.get('cdnUrl'),
defaultPoWDifficulty: config.get('defaultPoWDifficulty'), defaultPoWDifficulty: config.get('defaultPoWDifficulty'),
// one day explain why we need to do this - neuroscr
seedNodeList: JSON.stringify(config.get('seedNodeList')), seedNodeList: JSON.stringify(config.get('seedNodeList')),
certificateAuthority: config.get('certificateAuthority'), certificateAuthority: config.get('certificateAuthority'),
environment: config.environment, environment: config.environment,

@ -2,7 +2,7 @@
"name": "session-messenger-desktop", "name": "session-messenger-desktop",
"productName": "Session", "productName": "Session",
"description": "Private messaging from your desktop", "description": "Private messaging from your desktop",
"version": "1.0.7", "version": "1.0.8",
"license": "GPL-3.0", "license": "GPL-3.0",
"author": { "author": {
"name": "Loki Project", "name": "Loki Project",

@ -25,6 +25,7 @@ export type PropsData = {
isPublic?: boolean; isPublic?: boolean;
isRss?: boolean; isRss?: boolean;
isClosable?: boolean; isClosable?: boolean;
primaryDevice?: string;
lastUpdated: number; lastUpdated: number;
unreadCount: number; unreadCount: number;

@ -321,8 +321,10 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
private renderList() { private renderList() {
const { sentFriendsRequest } = this.props; const { sentFriendsRequest } = this.props;
const friends = window.getFriendsFromContacts(this.props.friends); const friends = window.getFriendsFromContacts(this.props.friends);
const length = Number(sentFriendsRequest.length) + Number(friends.length); const length = Number(sentFriendsRequest.length) + Number(friends.length);
const combined = [...sentFriendsRequest, ...friends]; const combined = [...sentFriendsRequest, ...friends];
const list = ( const list = (

@ -53,6 +53,8 @@ export type ConversationType = {
isSelected: boolean; isSelected: boolean;
isTyping: boolean; isTyping: boolean;
isFriend?: boolean; isFriend?: boolean;
isSecondary?: boolean;
primaryDevice: string;
hasReceivedFriendRequest?: boolean; hasReceivedFriendRequest?: boolean;
hasSentFriendRequest?: boolean; hasSentFriendRequest?: boolean;
}; };

@ -107,9 +107,9 @@ export const _getLeftPaneLists = (
const conversations: Array<ConversationType> = []; const conversations: Array<ConversationType> = [];
const archivedConversations: Array<ConversationType> = []; const archivedConversations: Array<ConversationType> = [];
const friends: Array<ConversationType> = []; const allFriends: Array<ConversationType> = [];
const receivedFriendsRequest: Array<ConversationListItemPropsType> = []; const allReceivedFriendsRequest: Array<ConversationListItemPropsType> = [];
const sentFriendsRequest: Array<ConversationListItemPropsType> = []; const allSentFriendsRequest: Array<ConversationListItemPropsType> = [];
const max = sorted.length; const max = sorted.length;
let unreadCount = 0; let unreadCount = 0;
@ -125,11 +125,11 @@ export const _getLeftPaneLists = (
} }
if (conversation.isFriend && conversation.activeAt !== undefined) { if (conversation.isFriend && conversation.activeAt !== undefined) {
friends.push(conversation); allFriends.push(conversation);
} }
if (conversation.hasReceivedFriendRequest) { if (conversation.hasReceivedFriendRequest) {
receivedFriendsRequest.push(conversation); allReceivedFriendsRequest.push(conversation);
} else if ( } else if (
unreadCount < 9 && unreadCount < 9 &&
conversation.isFriend && conversation.isFriend &&
@ -138,7 +138,9 @@ export const _getLeftPaneLists = (
unreadCount += conversation.unreadCount; unreadCount += conversation.unreadCount;
} }
if (conversation.hasSentFriendRequest) { if (conversation.hasSentFriendRequest) {
sentFriendsRequest.push(conversation); if (!conversation.isFriend) {
allSentFriendsRequest.push(conversation);
}
} }
if (!conversation.activeAt) { if (!conversation.activeAt) {
@ -152,6 +154,40 @@ export const _getLeftPaneLists = (
} }
} }
const filterToPrimary = <
T extends Array<ConversationType | ConversationListItemPropsType>
>(
group: Array<ConversationType | ConversationListItemPropsType>
): T => {
const secondariesToRemove: Array<string> = [];
group.forEach(device => {
if (!device.isSecondary) {
return;
}
const devicePrimary = group.find(c => c.id === device.primaryDevice);
// Remove secondary where primary already exists in group
if (group.some(c => c === devicePrimary)) {
secondariesToRemove.push(device.id);
}
});
// tslint:disable-next-line: no-unnecessary-local-variable
const filteredGroup = group.filter(
c => !secondariesToRemove.find(s => s === c.id)
);
return filteredGroup as T;
};
const friends: Array<ConversationType> = filterToPrimary(allFriends);
const receivedFriendsRequest: Array<
ConversationListItemPropsType
> = filterToPrimary(allReceivedFriendsRequest);
const sentFriendsRequest: Array<
ConversationListItemPropsType
> = filterToPrimary(allSentFriendsRequest);
return { return {
conversations, conversations,
archivedConversations, archivedConversations,

@ -19,6 +19,8 @@ describe('state/selectors/conversations', () => {
timestamp: 0, timestamp: 0,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id1',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -35,6 +37,8 @@ describe('state/selectors/conversations', () => {
timestamp: 20, timestamp: 20,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id2',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -51,6 +55,8 @@ describe('state/selectors/conversations', () => {
timestamp: 20, timestamp: 20,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id3',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -67,6 +73,8 @@ describe('state/selectors/conversations', () => {
timestamp: 20, timestamp: 20,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id4',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -83,6 +91,8 @@ describe('state/selectors/conversations', () => {
timestamp: 30, timestamp: 30,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id5',
type: 'direct', type: 'direct',
isMe: false, isMe: false,

Loading…
Cancel
Save