Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikunj committed Jul 31, 2020
2 parents b2073e8 + fad00a4 commit a8db1ce
Show file tree
Hide file tree
Showing 101 changed files with 2,495 additions and 1,648 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- development
- clearnet
- github-actions
- refactor-ts-react

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ tags

proxy.key
proxy.pub

*.tsbuildinfo
99 changes: 20 additions & 79 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,6 @@
"message": "Conversations",
"description": "Shown to separate the types of search results"
},
"friendsHeader": {
"message": "Friends",
"description": "Shown to separate the types of search results"
},
"contactsHeader": {
"message": "Contacts",
"description": "Shown to separate the types of search results"
Expand Down Expand Up @@ -991,18 +987,6 @@
"message": " Type your message",
"description": "Placeholder text in the message entry field"
},
"sendMessageDisabledSecondary": {
"message": "This pubkey belongs to a secondary device. You should never see this message",
"description": "Placeholder text in the message entry field when it is disabled because a secondary device conversation is visible"
},
"sendMessageDisabled": {
"message": "Waiting for friend request approval",
"description": "Placeholder text in the message entry field when it is disabled while we are waiting for a friend request approval"
},
"sendMessageFriendRequest": {
"message": "Send your first message",
"description": "Placeholder text in the message entry field when it is the first message sent to that contact"
},
"sendMessageLeftGroup": {
"message": "You left this group"
},
Expand Down Expand Up @@ -1318,6 +1302,22 @@
"message": "Typing Indicators",
"description": "Title of the typing indicators setting"
},
"multiDeviceDisabledTemporary": {
"message": "MultiDevice disabled temporarily",
"description": "Description of why multi device is disabled"
},
"multiDeviceDisabledTemporaryTitle": {
"message": "Changes to Multi-device",
"description": "Description of why multi device is disabled on app start"
},
"multiDeviceDisabledTemporaryDescriptionPrimary": {
"message": "You’re seeing this because you have a secondary device linked to your Session ID. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on <span style=\"color:#00f782\">August 6th</span>.</br></br>To read more about this change, visit the Session FAQ at <a href=\"https://getsession.org/faq\">getsession.org/faq</a>.",
"description": "Description of why multi device is disabled on app start for a primary device"
},
"multiDeviceDisabledTemporaryDescriptionSecondary": {
"message": "You’re seeing this because this is a secondary device in a multi-device setup. To improve reliability and stability, we’ve decided to temporarily disable Session’s multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on <span style=\"color:#00f782\">August 6th</span>.</br></br>To read more about this change, visit the Session FAQ at <a href=\"https://getsession.org/faq\">getsession.org/faq</a>.",
"description": "Description of why multi device is disabled on app start for a secondary device"
},
"messageTTL": {
"message": "Message TTL",
"description": "Title of the Message TTL setting"
Expand Down Expand Up @@ -1860,50 +1860,6 @@
}
}
},
"friendRequestPending": {
"message": "Friend request",
"description": "Shown in the conversation history when the user sends or recieves a friend request"
},
"friendRequestAccepted": {
"message": "Friend request accepted",
"description": "Shown in the conversation history when the user accepts a friend request"
},
"friendRequestDeclined": {
"message": "Session request declined",
"description": "Shown in the conversation history when the user declines a friend request"
},
"friendRequestExpired": {
"message": "Friend request expired",
"description": "Shown in the conversation history when the users friend request expires"
},
"friendRequestNotificationTitle": {
"message": "Friend request",
"description": "Shown in a notification title when receiving a friend request"
},
"friendRequestNotificationMessage": {
"message": "$name$ sent you a friend request",
"description": "Shown in a notification body when receiving a friend request",
"placeholders": {
"name": {
"content": "$1",
"example": "Bob"
}
}
},
"friendRequestAcceptedNotificationTitle": {
"message": "Friend request accepted",
"description": "Shown in a notification title when friend request was accepted by the other user"
},
"friendRequestAcceptedNotificationMessage": {
"message": "$name$ accepted your friend request",
"description": "Shown in a notification body when friend request was accepted by the other user",
"placeholders": {
"name": {
"content": "$1",
"example": "Bob"
}
}
},
"blockUser": {
"message": "Block User"
},
Expand Down Expand Up @@ -2270,18 +2226,6 @@
"message": "Conversations",
"description": "conversation tab title"
},
"friendsTab": {
"message": "Friends",
"description": "friend tab title"
},
"pendingAcceptance": {
"message": "Pending Acceptance",
"description": "Indicates that a friend request is pending"
},
"notFriends": {
"message": "Not Friends",
"description": "Indicates that a conversation is not friends with us"
},
"emptyGroupNameError": {
"message": "Group Name cannot be empty",
"description": "Error message displayed on empty group name"
Expand Down Expand Up @@ -2326,11 +2270,11 @@
"groupInvitation": {
"message": "Group Invitation"
},
"addingFriends": {
"message": "Adding friends to"
"addingContacts": {
"message": "Adding contacts to"
},
"noFriendsToAdd": {
"message": "No friends to add"
"noContactsToAdd": {
"message": "No contacts to add"
},
"noMembersInThisGroup": {
"message": "No other members in this group"
Expand Down Expand Up @@ -2534,9 +2478,6 @@
"displayNameEmpty": {
"message": "Display Name Is Mandatory"
},
"youHaveFriendRequestFrom": {
"message": "You have friend requests from..."
},
"members": {
"message": "$count$ members",
"placeholders": {
Expand Down
193 changes: 4 additions & 189 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
libloki,
libsession,
libsignal,
StringView,
BlockedNumberController,
libsession,
*/
Expand Down Expand Up @@ -615,171 +614,6 @@
}
});

// TODO: make sure updating still works
window.doUpdateGroup = async (groupId, groupName, members, avatar) => {
const ourKey = textsecure.storage.user.getNumber();

const convo = await ConversationController.getOrCreateAndWait(
groupId,
'group'
);
const oldMembers = convo.get('members');
const oldName = convo.getName();

const groupDetails = {
id: groupId,
name: groupName,
members,
active: true,
expireTimer: convo.get('expireTimer'),
avatar,
is_medium_group: false,
};

const recipients = _.union(convo.get('members'), members);

await window.NewReceiver.onGroupReceived(groupDetails);

if (convo.isPublic()) {
const API = await convo.getPublicSendData();

if (avatar) {
// I hate duplicating this...
const readFile = attachment =>
new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = e => {
const data = e.target.result;
resolve({
...attachment,
data,
size: data.byteLength,
});
};
fileReader.onerror = reject;
fileReader.onabort = reject;
fileReader.readAsArrayBuffer(attachment.file);
});
const attachment = await readFile({ file: avatar });
// const tempUrl = window.URL.createObjectURL(avatar);

// Get file onto public chat server
const fileObj = await API.serverAPI.putAttachment(attachment.data);
if (fileObj === null) {
// problem
window.warn('File upload failed');
return;
}

// lets not allow ANY URLs, lets force it to be local to public chat server
const url = new URL(fileObj.url);

// write it to the channel
await API.setChannelAvatar(url.pathname);
}

if (await API.setChannelName(groupName)) {
// queue update from server
// and let that set the conversation
API.pollForChannelOnce();
// or we could just directly call
// convo.setGroupName(groupName);
// but gut is saying let the server be the definitive storage of the state
// and trickle down from there
}
return;
}

const nullAvatar = undefined;
if (avatar) {
// would get to download this file on each client in the group
// and reference the local file
}
const options = {};

const isMediumGroup = convo.isMediumGroup();

const updateObj = {
id: groupId,
avatar: nullAvatar,
recipients,
members,
is_medium_group: isMediumGroup,
options,
};

if (oldName !== groupName) {
updateObj.name = groupName;
}

const addedMembers = _.difference(updateObj.members, oldMembers);
if (addedMembers.length > 0) {
updateObj.joined = addedMembers;
}
// Check if anyone got kicked:
const removedMembers = _.difference(oldMembers, updateObj.members);
if (removedMembers.length > 0) {
updateObj.kicked = removedMembers;
}
// Send own sender keys and group secret key
if (isMediumGroup) {
const { chainKey, keyIdx } = await window.MediumGroups.getSenderKeys(
groupId,
ourKey
);

updateObj.senderKey = {
chainKey: StringView.arrayBufferToHex(chainKey),
keyIdx,
};

const groupIdentity = await window.Signal.Data.getIdentityKeyById(
groupId
);

const secretKeyHex = StringView.hexToArrayBuffer(
groupIdentity.secretKey
);

updateObj.secretKey = secretKeyHex;
}

convo.updateGroup(updateObj);
};

window.doCreateGroup = async (groupName, members) => {
const keypair = await libsignal.KeyHelper.generateIdentityKeyPair();
const groupId = StringView.arrayBufferToHex(keypair.pubKey);

const primaryDeviceKey =
window.storage.get('primaryDevicePubKey') ||
textsecure.storage.user.getNumber();
const allMembers = [primaryDeviceKey, ...members];

const groupDetails = {
id: groupId,
name: groupName,
members: allMembers,
recipients: allMembers,
active: true,
expireTimer: 0,
avatar: undefined,
};

await window.NewReceiver.onGroupReceived(groupDetails);

const convo = await ConversationController.getOrCreateAndWait(
groupId,
'group'
);

convo.updateGroupAdmins([primaryDeviceKey]);
convo.updateGroup(groupDetails);

textsecure.messaging.sendGroupSyncMessage([convo]);
appView.openConversation(groupId, {});
};

window.confirmationDialog = params => {
const confirmDialog = new Whisper.SessionConfirmView({
el: $('body'),
Expand Down Expand Up @@ -1486,9 +1320,6 @@
if (messageReceiver) {
await messageReceiver.close();
}

const USERNAME = storage.get('number_id');
const PASSWORD = storage.get('password');
const mySignalingKey = storage.get('signaling_key');

connectCount += 1;
Expand Down Expand Up @@ -1517,31 +1348,18 @@
);
window.lokiPublicChatAPI = null;
window.feeds = [];
messageReceiver = new textsecure.MessageReceiver(
USERNAME,
PASSWORD,
mySignalingKey,
options
);
messageReceiver = new textsecure.MessageReceiver(mySignalingKey, options);
messageReceiver.addEventListener(
'message',
window.NewReceiver.handleMessageEvent
);
window.textsecure.messaging = new textsecure.MessageSender(
USERNAME,
PASSWORD
);
window.textsecure.messaging = new textsecure.MessageSender();
return;
}

initAPIs();
await initSpecialConversations();
messageReceiver = new textsecure.MessageReceiver(
USERNAME,
PASSWORD,
mySignalingKey,
options
);
messageReceiver = new textsecure.MessageReceiver(mySignalingKey, options);
messageReceiver.addEventListener(
'message',
window.NewReceiver.handleMessageEvent
Expand All @@ -1560,10 +1378,7 @@
logger: window.log,
});

window.textsecure.messaging = new textsecure.MessageSender(
USERNAME,
PASSWORD
);
window.textsecure.messaging = new textsecure.MessageSender();

// On startup after upgrading to a new version, request a contact sync
// (but only if we're not the primary device)
Expand Down

0 comments on commit a8db1ce

Please sign in to comment.