Commit Graph

111 Commits

Author SHA1 Message Date
239d136788 jamiaccount: check if uri is valid before adding contact
Else, if a client calls addContact with an invalid uri, it will
create a conversation with an invalid contact and the client will
be in a bugguy state.

git.jami.net/savoirfairelinux/jami-client-android/-/issues/1681
Change-Id: Id6227c45c279c78aac0a191b6ae688ebe0d3d1c4
2024-05-31 10:24:12 -05:00
d9d9d08d04 conversation_module: support editMessage on file transfer
This allow users to delete files. Moreover, change edited type and
use edited commit type instead.

GitLab: #796
git.jami.net/savoirfairelinux/jami-client-qt/-/issues/1287
Change-Id: Ida04c15cf1570de2f7707ce547be9f4a5e638245
2024-05-27 14:39:25 -05:00
6583436a37 test: fix ut_typers
GitLab: #968
Change-Id: I9049d376984d480f686a369237b8dcab29144f45
2024-03-05 12:13:03 -05:00
b307501a7b CTAD: re-add template when CTAD fails
In a class definition, the template deduction is failing.

Change-Id: If725c6a076fc4ac07ab0cf493959e51820abdc85
2024-03-05 08:39:02 -05:00
16b77dd10c remove mutex template
Change-Id: I0aacf47c70a0de4fcd1a68f6688cf0ee0c551934
2024-03-04 10:38:00 -05:00
09ec8e6f43 conversation: re-design sending/sent status
The goal of this patch is to allow the clients to get a better
sent/read status from the daemon.

API doesn't change much, but internal logic got some changes. For the
client:
+ SwarmMessage now contains a map<string,int> status where string is the
  uri of a member, int is the status (0 = sending, 1 = sent, 2 = read)
+ cancelMessage is removed as not used anymore (sendMessage with flag=1
  will edit a message)
+ getMessageStatus is removed as the status is sent in the SwarmMessage
+ accountMessageStatusChanged is now emitted for swarm messages when a
  fetch or setDisplay occurs. Client must handle this signal correctly.
+ Previous code to manage last displayed, fetched status is now merged
  with message status
+ Sync info is done when the sync is opened, else status are not updated
  correctly

GitLab: #948
Change-Id: I60763d4de8a995c6fc9f6df6434e266211f8dc2f
2024-02-15 13:52:39 -05:00
0a131c0a2f conversation: remove reactions on a message deletion
GitLab: #945
Change-Id: I23e32f33f405c7c6534b0d4667d3d27d8a045e77
2024-02-12 15:12:27 -05:00
9ac6717a90 jamiaccount: init convModule for disabled accounts
Change-Id: Iec90e9d91f933531a96d4e84e6a3ed242caf1422
2024-01-25 08:54:13 -05:00
b122e248f3 conversationrepository: add user device on profile update
If the first interaction from a device in a conversation is a
profile update, the certificate was not added correctly causing
the conversation to be illformed

GitLab: #946
Change-Id: I07f1735639c2dbf89ba2b2e6b7d9c3f57e5823e4
2024-01-19 11:09:28 -05:00
340e4d0d6d test: fix callback crash
Change-Id: Ia6d5e2c8f211e5206dec214232c929e624c307de
2024-01-12 09:40:03 -05:00
3c3370a6f1 test: add test for keeping reaction on edition
Change-Id: Ibeb67458e76cf413a53120fe3382bf625c7f0de8
2024-01-09 11:55:47 -05:00
40dddee226 misc: update copyright to 2024
Change-Id: I829473d42b2b90f26ed2d93bbde063a21ce0952c
2024-01-02 17:26:29 -05:00
2364669831 tests: remove invalid tests
Sending a 1:1 message after a removeContact doesn't create a new
invite anymore

Change-Id: I0faf4a8134bb5d45672637364bd06fbbe6b20661
2023-12-28 16:05:40 -05:00
8468f15927 conversation: move logic of message management in daemon
This heavily changes the API for the client. The goal here is
to move the logic to construct the history to show in the daemon
and not the client. This has several advantages:

1. Logic is common across every platforms, so bugs should not be
platform-specific
2. Client got less logic
3. Signal are simplified, if an edition comes, "MessageUpdated"
will be triggered instead MessageReceived.
4. Some tests are added for linearizing the history.
5. Search on edition is fixed.

Tests got heavily re-written, but the content didn't change (2 tests
are added, the rest is simplification).

GitLab: #831
Change-Id: Ie7c81077067e9e49db1dd396829c9225c0512c16
2023-12-28 16:05:40 -05:00
057cb34917 conversation_module: parallelize loadConversations()
and avoid to call it twice

Change-Id: I75e7943a2552c1834f697a616b0c115955122abf
2023-12-14 23:10:26 -05:00
8b7afc852a swarm_manager: freely connect to nodes with a p2p link
setKnownNodes will add new nodes that may be already connected
with a TCP link, but maintainBuckets may not choose those nodes,
delaying the bootstrap.
If we detect a new node that we're already connected with, we can
add it in the list of nodes we want to connect with.

Change-Id: I422a32495693e1e2d925a3af127a4a59903c1833
2023-12-08 10:25:17 -05:00
737e2f117c migrate to std::filesystem
Change-Id: I0ecc36493d10399c72a52aa1aa2dad48ee182296
2023-09-21 11:12:26 -04:00
06462489e8 migrate to std::filesystem
Change-Id: I51c2058d9916c0f7307ce026aa08fc6b060fa85e
2023-09-18 17:43:47 -04:00
299e0c4a91 conversation: use certificates from repository during validation
If a new device is doing some actions for the first time, the merge
will detect a new certificate that is not yet in the certificate
store (unless if the sender is the new device).
This will block the validation. So, instead, use the certificate
in the processed commit.

GitLab: #892
Change-Id: I0ab492e700a2aa7ef4258e2bf711117f67e29fae
2023-09-18 09:01:56 -04:00
459e58a6d2 conversation_module: fix remove on replay
When a trust request is confirmed with an old conversationId, new
messages will be transferred and the conversation will be replaced
to avoid duplicates.
However, because erasePending() wasn't used after a lock, the
removal was failing with "operation not permitted" causing a duplicate
to stay.
A test is added to avoid any further regression.

Change-Id: Ic0fd960005a064ddd7b410f014f67d9125e50446
2023-09-12 09:55:26 -04:00
c6926445e5 update dhtnet and cleanup fileutils
Change-Id: I051dfe0522f20592d70f4286a104bc7029488186
2023-09-01 09:49:05 -04:00
979c1f731a conversationrepository: handle invalid display name
If the signature creations fails due to an invalid display name, the
signature will use the device Id instead.

GitLab: #885
Change-Id: Ifddf0c8afec03f26f43aebe12e56d028ca5200d0
2023-08-10 13:13:35 -04:00
25f6415265 switch to dhtnet
Change-Id: Ib53b7e170df59f873fbd85f6e7d4bf338d04cb9c
2023-07-27 12:51:32 -04:00
eb62840618 conversation_module: loadConversations should set removing flag
This fix the error "No conversation detected for..."

Change-Id: I95769b89ceac6c03bc8abab87978e154500a6319
2023-06-16 15:00:19 -04:00
439e6f24cf contact_list: force removeContact to update all components
If a contact is added, removed and a new trust request generated
and removed with "removeContact" it wasn't removing the trust request
because the contact wasn't considered as active and the banned status
didn't change.
Removing this return condition force all components to update and
supports client if they use removeContact instead of declineTrustRequest.
This avoid useless complexity with isActive, because if isActive() is
false, removeContact will not change the result and isActive() will
still return false.

A test is added.

GitLab: #855
Change-Id: I4385c2a480f6cfa5de3785a08bc2193eeb9a24a1
2023-06-15 10:53:07 -04:00
632ec7e344 conversation_module: try to clone requests on bootstrap
Since the DRT, we're not using trackPresence to start syncing
with other members of the conversation but "bootstrap".
For bootstraping conversation's requests we should try to clone
it with the members marked in the convInfo.

Also fix one incorrect test.

Change-Id: I8cbefe266c15c637ef23350220a71a616ddefab6
2023-06-14 15:42:08 -04:00
79e0e6a864 misc: fix typo
Change-Id: If56a102c1861b762623acdbe11358b0bc85085c5
2023-06-07 14:36:46 -04:00
f77182eb79 misc: fix testMergeAfterMigration
Due to certStore changes, we should force the certificate pinning
after forceReloadAccount

Change-Id: I1a98f86847607e9c48b91b5448185e3d25763a49
2023-06-07 14:35:39 -04:00
288113d666 conversation_module: fix clone from multiple devices
Multiple changes are included in this patch:
+ Remove pendingConversationFetchMtx_ and use conversationsMtx_
instead to avoid any potential weird state
+ Remove RepeatedTask causing two fetch operations to happen
+ Remove bugguy map access causing a fetch to happen even if
previously removed

A test for the problematic scenario is added to avoid any future
regression.

Change-Id: I9b5f93fc11f053a0552e5f34711130d5a5c22c05
2023-05-18 17:42:17 -04:00
3670cabd61 certstore: split per account
This allow to keep different status between accounts, remove
certificates when the account is removed. And this avoid
to use the same certificate store/trust store shared across
accounts.

Change-Id: Iba5df5c0768cefe7a861cab689ffb8ff770d8475
2023-05-01 13:14:37 -04:00
cf78a2ba4d drt: fix ut
- mobile shutdown: added time / block for callback
- check existing connection before removing node from rt
- threadpool instead of lock for shutdown

Change-Id: I79fc9506cd465763cd38723aedd08a59a0573970
2023-04-20 15:23:25 -04:00
b3d8577db4 DRT: integrate DRT components to conversation
This patches avoid swarm members to connect to all devices of the
conversation by using a better routing mechanism.
The idea is to add a component called "DRT" that will store, like
a DHT, a routing table containing the known devices of the conversation.
The DRT is bootstraped with the list of the devices that already wrote
a message in the conversation, else with some other members that have
devices present (because lot of devices may never have written any message).
Moreover, because a user can import an old backup without the conversation
and without other devices present, we also try to connect to 2 other random
members because they may never connect if they are on an old back-up.

Once bootstraped, the DRT is used to decide to who a user should be
connected. And it will use approximately log(N) connections (instead
of N like before). So, when sending a message, a user will send to
connected peers (and some mobiles). Then, some peers in the conversation
will get the message, pull it, then announce to their nearest peers (and
some mobiles) until all peers got the new message. To avoid infinite loop,
we check if we already got the commit and if we have something to announce.

Finally, if somebody disconnect, this will cause the DRT to try to re-fill
its bucket and try to connect to a new device.

GitLab: #297
Change-Id: I137788c77219fe74287585882260547cc5628784
2023-04-13 09:16:19 -04:00
c6cd037b68 conversation_module: add "created" to syncing
So that clients can show whenever a syncing conversation was added

Change-Id: Iccee12066384e0ccc78e3a96b8e5137b79bfa314
2023-03-22 13:44:18 -04:00
f119ea1416 conversation: synchronize read status across device
On the same model as conversation's preferences

GitLab: #815
Change-Id: I15461d40c5d9e83e39ef5f83b6b663d9427615f8
2023-02-20 13:25:28 -05:00
565ff0f025 conversation: sync preferences right after clone
Add preferences to original sync information sent and use it after
a clone.

GitLab: #814
Change-Id: I742ba8ff3ddf56d1f73658fffa0675ce481981e0
2023-02-20 09:01:20 -05:00
4166137736 misc: Update copyright years to 2023
Change-Id: Ia80fc12ba65b1abd516af205e6664261ae2e33fe
2023-02-06 01:46:45 -05:00
ddb36d0fe9 conversation: do not add conversation request if accepted
Change-Id: I7fb785243b6684ab9a02f9364e65b118a88c120d
2023-01-18 12:55:31 -05:00
33e6ac4348 conversationrepository remove "<>" from display name
This should not appears in user.name as it will fail during
the signature creation.

Change-Id: I8bc04b9fdd60cb6c80fc267d064433ab331f6338
2023-01-05 10:36:43 -05:00
43c260423a misc: fix some raceCondition in tests
Wait for call is current before stopping it

Change-Id: I3286f8564a209aec5fd1130a11648552b37057b9
2022-12-29 13:30:55 -05:00
e037e6358c conversation: add case sensitive flag on searchConversation
This allow the search request to be case insensitive by default

Change-Id: I97d0e9c01a2ca311faba7136cfda460ce7ad9957
2022-11-21 10:18:13 -05:00
fa03e232b7 swarm: add reaction support
This is a pretty trivial patch as all the necessary logics are
already supported by the deamon.
A client can use sendMessage with flag = 2 to add a reaction.
This only adds a "react-to" in the body of the message that the
client can interpret.
To remove a reaction, the client can use editMessage (and set the
body to "" for the id of the reaction), also there is no limit
on the content of the reaction and multiple reactions can be added
to the same message.
For non compatible clients, it will be shown as a simple text message
as it's the same type.

Change-Id: I7b13d32771109118b94ed17d0b918e66487e94bb
2022-11-21 10:17:57 -05:00
5b56cc7e42 fileTransfer: massive cleanup
The new logic is there! Swarm is working since some time now, so we can
remove previous logic.

GitLab: #524
Change-Id: I5ca172e9349694d944c9561d97fe8a63d190ebf3
2022-11-18 15:22:23 -05:00
ac7ce59c42 connectivity: initial split from jami-related components
As a measure of refactorization of the code and to prepare to the
development of dhtnet, the following changes aims at seperating
jami-specific code to connectivity-specific code.

GitLab: #778
Change-Id: Iaa08100f7d61c80292f039a5aae66819cc85b0e9
2022-11-04 11:00:17 -04:00
d54a84ec0b Replace DRing for libjami
It's not possible to replace the DRing namespace for jami because of conflicts
with namespaces and classes defined under the jami namespace.  Thus, use libjami
as the namespace.

Script to reproduce:

 rg -l DRing | sort | uniq | awk '$0 !~ /NEWS/' | xargs sed -i -e 's|DRing|libjami|g'
 rg -l DRING_ | sort | uniq | xargs sed -i -e 's|DRING_|LIBJAMI_|g'
 sed -i -e 's|dring|jami|g' src/jami/CMakeLists.txt
 sed -i -e 's|dring|jami|g' src/jami/def.h

Change-Id: I80e8c8b58a7586527a016bbef850bab07869c473
2022-10-29 16:49:27 -04:00
db3e62e415 conversation: fix logUntil
logUntil should retrieve the commits with the commit passed.
Add a LogOptions parameter to avoid too much parameters.

Change-Id: I77a0150b135b14fe44577747d2b1a86cb2cf2509
2022-10-27 15:52:26 -04:00
0f6b74b194 conversation: add support for message edition
For now, only be able to edit messages from our-self and with the
text/plain type

Change-Id: I20c6ed7dad3892f0fa655812242b9ca6e77e69b3
GitLab: #316
2022-10-24 14:29:19 -04:00
b28a5cb85d convmodule: avoid incorrect states
In some cases the file "contacts" was badly synced. Also, if for any
reason "contacts" is not correctly formed, we may be able to fix it.

This patch handles two cases of failures:

1. If the contact details doesn't contain any conversationId BUT
a 1:1 conversation is found with this contact, we update the
conversationId in the details.

2. If, for some reason, multiple 1:1 conversations are detected
with the same contact, we only keep the one in the details, as
it should be the correct one.

This should fix the fact that for some conversation, calls are not
written in the history (cause getOneToOneConversation() returns
nothing).

Change-Id: I5dd9fc51999540d8a4230f8fdce828a461da752a
2022-10-21 12:07:05 -04:00
483b2b97ae ut_conversation: fix build
Change-Id: I7362b02cc1fd557cf454ccc29d60ff88a53f4afc
2022-10-20 09:26:55 -04:00
a4ff4abe70 swarm: add method to save user's preferences
This store user's preferences per conversation into
conversation_data/<convId>/preferences
In this way, the daemon is able to sync this file across devices
and remove preferences at the same time we remove the conversation.

For now, only support "color" and "ignoreNotifications"

The preferences are synced via partial SyncMsg sent across devices.

Change-Id: I8fe74cc06733ad61d45d721e0264b1941d4cf122
2022-10-06 14:47:30 -04:00
cc2f9efb47 misc: fix tests
+ search method was incorrect if no type provided
+ some tests were not waiting for correct signals

Change-Id: If6ba59829defb168f51c4a8e25f2054cd649b8c2
2022-09-08 14:07:31 -04:00