Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Friend request fixes #50

Merged
merged 17 commits into from Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Expand Up @@ -1590,6 +1590,10 @@
"message": "Friend 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"
Expand Down
22 changes: 14 additions & 8 deletions js/background.js
Expand Up @@ -570,12 +570,6 @@
}
});

Whisper.events.on('showFriendRequest', friendRequest => {
if (appView) {
appView.showFriendRequest(friendRequest);
}
});

Whisper.events.on('calculatingPoW', ({ pubKey, timestamp }) => {
try {
const conversation = ConversationController.get(pubKey);
Expand Down Expand Up @@ -1259,7 +1253,7 @@
async function initIncomingMessage(data, options = {}) {
const { isError } = options;

const message = new Whisper.Message({
let messageData = {
source: data.source,
sourceDevice: data.sourceDevice,
sent_at: data.timestamp,
Expand All @@ -1268,7 +1262,19 @@
unidentifiedDeliveryReceived: data.unidentifiedDeliveryReceived,
type: 'incoming',
unread: 1,
});
preKeyBundle: data.preKeyBundle || null,
};

if (data.type === 'friend-request') {
messageData = {
...messageData,
type: 'friend-request',
friendStatus: 'pending',
direction: 'incoming',
}
}

const message = new Whisper.Message(messageData);

// If we don't return early here, we can get into infinite error loops. So, no
// delivery receipts for sealed sender errors.
Expand Down