Auto accept friend request messages if we were already friends with the user.

Lint fixes for previous files.
pull/280/head
Mikunj 6 years ago
parent 883b94ff92
commit 12cce8fe47

@ -4,7 +4,6 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
@ -17,6 +16,7 @@ Steps to reproduce the behavior:
If applicable, add screenshots or log files to help explain your problem.
**Other information (please complete the following information):**
- Device: [e.g. PC, Mac]
- OS: [e.g. Ubuntu 16.04, Windows 10]
- Loki messenger Version or Git commit hash:
* Device: [e.g. PC, Mac]
* OS: [e.g. Ubuntu 16.04, Windows 10]
* Loki messenger Version or Git commit hash:

@ -89,11 +89,11 @@ can public keys. To test the P2P functionality on the same machine, however, req
that each client binds their message server to a different port.
You can use the following command to start a client bound to a different port.
```
yarn start-multi
```
For more than 2 clients, you can setup additional storage profiles and switch
between them using the `NODE_APP_INSTANCE` environment variable and specifying a
new localServerPort in the config.
@ -149,12 +149,13 @@ So you wanna make a pull request? Please observe the following guidelines.
the translations in
[Transifex](https://www.transifex.com/projects/p/signal-desktop).
-->
* Never use plain strings right in the source code - pull them from `messages.json`!
You **only** need to modify the default locale
[`_locales/en/messages.json`](_locales/en/messages.json).
<!-- TODO:
Other locales are generated automatically based on that file and then periodically
uploaded to Transifex for translation. -->
<!-- TODO:
Other locales are generated automatically based on that file and then periodically
uploaded to Transifex for translation. -->
* [Rebase](https://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-rebase/) your
changes on the latest `development` branch, resolving any conflicts.
This ensures that your changes will merge cleanly when you open your PR.

@ -1567,7 +1567,24 @@
let autoAccept = false;
if (message.get('type') === 'friend-request') {
if (conversation.hasSentFriendRequest()) {
/*
Here is the before and after state diagram for the operation before.
None -> RequestReceived
PendingSend -> RequestReceived
RequestReceived -> RequestReceived
Sent -> Friends
Expired -> Friends
Friends -> Friends
The cases where we auto accept are the following:
- We sent the user a friend request and that user sent us a friend request.
- We are friends with the user, and that user just sent us a friend request.
*/
if (
conversation.hasSentFriendRequest() ||
conversation.isFriend()
) {
// Automatically accept incoming friend requests if we have send one already
autoAccept = true;
message.set({ friendStatus: 'accepted' });
@ -1575,7 +1592,7 @@
window.libloki.api.sendFriendRequestAccepted(
message.get('source')
);
} else if (!conversation.isFriend()) {
} else {
await conversation.onFriendRequestReceived();
}
} else {

Loading…
Cancel
Save