Commit Graph

99 Commits

Author SHA1 Message Date
Patryk Osmaczko 8dd8b1ae45 feat: implement community members count
iterates: status-im/status-desktop#8016
2023-03-29 17:08:41 +02:00
Pascal Precht 7bc03e22f7 Do not automatically decline requests in manual accept
When community owners accept pending requests manually, they would be
declined in that process if the request doesn't fullfill the required
token permission criteria.

We don't want this to automatically reject those requests anymore,
instead, owners have to manually reject the requests.
2023-03-23 12:04:59 +01:00
Pascal Precht 2cbced95c5 Check token funds when handling community requests to join
This adds checks to `HandleCommunityRequestToJoin` and
`AcceptRequestToJoinCommunity` that ensure a given user's revealed
wallet addresses own the token funds required by a community.

When community has token permissions of type `BECOME_MEMBER`, the
following happens when the owner receives a request:

1. Upon verifying provided wallet addresses by the requester, the owner
   node accumulates all token funds related to the given wallets that
   match the token criteria in the configured permissions
2. If the requester does not meet the necessary requirements, the
   request to join will be declined. If the requester does have the
   funds, he'll either be automatically accepted to the community, or
   enters the next stage where an owner needs to manually accept the
   request.
3. The the community does not automatically accept users, then the funds
   check will happen again, when the owner tries to manually accept the
   request. If the necessary funds do not exist at this stage, the
   request will be declined
4. Upon accepting, whether automatically or manually, the owner adds the
   requester's wallet addresses to the `CommunityDescription`, such that
   they can be retrieved later when doing periodic checks or when
   permissions have changed.
2023-03-23 08:40:31 +01:00
Pascal Precht 051314aad0 feat: add verified wallet accounts to community requests
This commit extends the `CommunityRequestToJoin` with `RevealedAddresses` which represent wallet addresses and signatures provided by the sender, to proof a community owner ownership of those wallet addresses.

**Note: This only works with keystore files maanged by status-go**

At high level, the follwing happens:

1. User instructs Status to send a request to join to a community. By adding a password hash to the instruction, Status will try to unlock the users keystore and verify each wallet account.
2. For every verified wallet account, a signature is created for the following payload, using each wallet's private key

   ``` keccak256(chatkey + communityID + requestToJoinID) ``` A map of walletAddress->signature is then attached to the community request to join, which will be sent to the community owner
3. The owner node receives the request, and if the community requires users to hold tokens to become a member, it will check and verify whether the given wallet addresses are indeed owned by the sender. If any signature provided by the request cannot be recovered, the request is immediately declined by the owner.
4. The verified addresses are then added to the owner node's database such that, once the request should be accepted, the addresses can be used to check on chain whether they own the necessary funds to fulfill the community's permissions

The checking of required funds is **not** part of this commit. It will be added in a follow-up commit.
2023-03-22 13:50:25 +01:00
Michal Iskierko 736766ec37 fix(AddCommunityToken): Change AddCommunityToken API call
The function returns object with image converted to base64 format.

Issue #9866
2023-03-22 13:45:53 +01:00
Andrea Maria Piana 5d81866957 Add request to response when canceling request 2023-03-14 13:50:18 +00:00
Michal Iskierko 8a296407f3 fix(GetCommunityTokens): Change API call - use only communityId param
Fix #9725
2023-03-06 10:46:41 +01:00
Pascal Precht 596660c110 feat: add CommunityTokenPermission to community description
This adds token permission capabilities to CommunityDescription such that token permissions can be created, updated and deleted.
2023-03-03 09:46:49 +01:00
Michal Iskierko d0cc036d48 feat(CommunityTokens): Keep community token details in database
New table for community tokens.
API for get,add, update community token.

Issue #9233
2023-02-27 10:37:54 +01:00
Mikhail Rogachev f25088483c
feat: Add seen/unseen activity center setting (#3148)
* feat: Add seen/unseen activity center state

* feat: ActivityCenterState for grouping ActivityCenter unread messages cnt and seen state

* feat: always use messenger's addActivityCenterNotification & add state to the response

* Remove unused activity center endpoints form api and fix test
2023-02-17 14:08:08 +04:00
Pascal Precht f31e40264e refactor(import-tool): process import data in chunks
This commit refactors the discord import tool such that,
instead of loading all data to be imported into memory at
once, it will now perform the import on a per file basis.

This improves the memory pressure for the node performing
the import and seems to increase its performance as well.
2023-01-30 12:23:56 +01:00
Mikhail Rogachev ee9f8edfcf
Mark as read acivated notifications with CTA (#3126)
* fix: Accepting or dismissing contact request should mark AC notification as read

* fix: Accepting or declining community request should mark AC notification as read

* fix: Read notification status fo identity verification requests

* fix: Save whole notification object while handling contact requests

* fix: Remove unused functions from activity_center_persistence

* fix: Use Accepted and Dismissed flags for AC notifications with CTA

* fix: Mark notification as unread when we handle accepted verification request

* fix: Replace Warn with Error on fail to save notification, test fixes

* fix: Fix conditions for fetching AC notifications from the db

* fix: Review fixes for err name and conditions array
2023-01-28 13:52:53 +04:00
Pascal Precht efbad4e9bc fix(DiscordImport): don't allow imports of files bigger than 50 MB
See https://github.com/status-im/status-desktop/issues/9261 for more info
2023-01-24 21:40:17 +01:00
Pascal Precht b5964348a1 fix(communities): ensure archive import is only cancelled if not already marked as such
There were cases where this caused a crash, as handling magnetlinks would try to close
an already closed tasked channel

See https://github.com/status-im/status-desktop/issues/8996 for more information.

This commit extends the task struct such that it can be marked as cancelled and safely
read and written by multiple go routines.
2023-01-24 08:58:40 +01:00
Pascal Precht eb2b4b7cdc refactor(Communities): ensure generated archives don't exceed max cap
This introduces an addition constraint to archive generation, in which the payload + signature size of all partitioned message that go into an archive should not exceed a certain
threshold.

This is to ensure that archives won't get too big when they are later read into memory.
2023-01-20 17:09:00 +01:00
Icaro Motta e40cbfc28f
feat: Support fetching accepted Activity Center notifications by multiple types (#3088)
Summary
=======

- [x] Changes endpoint ActivityCenterNotificationsBy to support fetching
  multiple types of notification in a single query.
- [x] Adds endpoint UnreadAndAcceptedActivityCenterNotificationsCount to
  allow the mobile client to fetch the count of unread & accepted
  notifications.
- [x] Add `golangci-lint` to Nix shell. This was possible since PR
  https://github.com/status-im/status-go/pull/3087 was merged.

Notes
=====

- If you'd like to understand why these changes are needed, please see
  the mobile PR https://github.com/status-im/status-mobile/pull/14785,
  or issue https://github.com/status-im/status-mobile/issues/14712
- All changes should be completely backwards compatible, and there
  should be no impact for the desktop app.
- The mobile client has been already tested using this branch.
2023-01-20 09:45:32 -03:00
Pascal Precht f85c500e9a Resume import of message history archives upon bootstrap
This adds the functionality that history archives continue to be imported
in case the import has been interrupted the last time the app/client
was running.

This typically happens when users don't wait for an ongoing import to finish,
which sometimes can take a while. Users then close the app/kill the client
which leaves the database in a state where there's downloaded archives that
haven't been fully imported.

Prior to this change, the node will have to wait until it receives a new
magnetlink that it hasn't seen before, until it processes imports again.
This can take several days.

Now, it will check on startup if there are any archives left to be imported
and resumes the import from there.
2023-01-20 07:57:24 +01:00
frank ec7c0e9c7d
Sync all devices after initial pairing (#3047) 2023-01-06 20:21:14 +08:00
Pascal Precht dd8be1d8b0 feat(communities): add magnetlink to RequestToJoinResponse
This is done so that when member join a community by being accepted by
the community owner, they also receive the most up-to-date magnetlink
along with it.
2022-12-14 13:43:43 +01:00
Pascal Precht 4bddfbd466 chore: better community archive protocol logs 2022-12-13 16:13:15 +01:00
Jonathan Rainville d87ed0e357 fix(community): don't delete chat and messages when leaving community
This creates a smoother experience for users when they leave a community since they can see the exact same messages they had before without having to rely on the mailserver.
2022-12-09 14:43:56 -05:00
Pascal Precht 8ac154ee0c fix: don't keep Messenger from starting when torrent client fails to
start

There are various cases that could make the torrent client fail to
start. We don't want this to keep the entire messenger from starting.
2022-12-06 18:19:36 +01:00
Michal Iskierko 8fc7d921a7 fix(ImportCommunity): Setting admin roles during import community.
Issue #7414
2022-12-06 10:25:21 +01:00
Pascal Precht 22b5690cda feat: add signal indicating that history messages are being imported
In order to give clients more insights about archive messages being
processed, we're adding this additional signal that informs clients when
the import of downloaded history archive messages has started.
2022-12-05 10:51:53 +01:00
frank 684e9654de
Allow owner/admin to delete messages of a community (#2958) 2022-12-02 19:34:02 +08:00
Pascal Precht 194f26f3b4 feat: add signal for starting history archive downloads 2022-12-01 16:12:00 +01:00
Michal Iskierko 6e96586bdb fix(RequestCommunityInfoFromMailserver): Add useDatabase flag to read/not read community info before requesting mailserver..
Fix #2878
2022-11-30 11:10:13 +01:00
Pascal Precht 019d520e28 fix(communities): properly delete remove chats when handling community
updates

When channels where removed from communities by the community owner,
community members would not remove the chats in their own databases.

See https://github.com/status-im/status-desktop/issues/8000 for more
info.

This commit ensures that nodes delete removed chats from their local
chats table and also deregister the corresponding transport filters.
2022-11-24 11:50:25 +01:00
Andrea Maria Piana c85df62d3c Sync community encryption keys 2022-11-15 10:11:01 +00:00
Pascal Precht d216840db8 feat(communities): add community images to import progress signal
This is needed so clients can render the selected community image
while the import is running.
2022-11-07 17:16:00 +01:00
Pascal Precht c528660aa3 fix(communities): improve error message about duplicated chat names
We don't allow multiple channels with the same name in communities.
Discord allows for multiple channels with the same name (living in
different categories), so this is an error case in our import tool.

This commit improves the user facing error message of this scenario.
2022-11-04 13:24:20 +01:00
Pascal Precht caa20e616e feat(communities): handle markdown in imported discord messages 2022-10-28 20:03:39 +02:00
Boris Melnik 63d46481fd
feat(communities): Cancel request to join community (#2915) 2022-10-28 11:41:20 +03:00
Pascal Precht 0bdb596d3b feat: introduce discord import tool 2022-10-28 09:52:26 +02:00
Mikhail Rogachev 60cb15739d
feat(ActivityCenter): Add community membership AC notifications (#2886)
* feat(ActivityCenter): Add community request AC notification

* feat(ActivityCenter): Add CommunityID to AC notification

* feat(ActivityCenter): Add membership status for community membership AC notifications

* feat(ActivityCenter): Add tests for community notifications and fix naming

* Add notification for kicked from community action

* feat(ActivityCenter): Fix for missing notification objects for tests
2022-10-26 02:06:20 +04:00
Pascal Precht 7eb66d09e7 feat(communities): add encryption suppord to archive protocol 2022-10-24 12:35:38 +02:00
Andrea Maria Piana bef211b5d6 Send all encryption keys 2022-10-20 12:19:44 +01:00
Pascal Precht dd49c4c954 feat(communities): add archiveLogger for stdout logs
The default logger writes to `geth.log`, which makes debugging
the archive protocol pretty hard.

This adds an additional logger that logs to stdout, while keeping
the default logger intact for production.
2022-10-14 16:31:21 +02:00
Anthony Laibe d9b44777c9
feat: update opensea testnet to use goerli (#2894) 2022-10-12 09:59:38 +02:00
Patryk Osmaczko 73a45dd58e feat: add `SpectateCommunity` api
- added `SpectateCommunity` endpoint, it is supposed to be used in
  scenarios where we want to "Go to public Community" and see its
  content without joining
- added `spectated` field to `Community`, it means we are observing the
  community and its chats but we are not members

Use case:
https://github.com/status-im/status-desktop/issues/7072#issuecomment-1246560885
2022-10-06 21:21:37 +02:00
Pascal Precht eb4ab9316c fix(communities): ensure existing archives are seeded on startup 2022-09-19 15:34:29 +02:00
Patryk Osmaczko 65be6f2b96 feat: add and distribute `chatIdentity.FirstMessageTimestamp`
`FirstMessageTimestamp` enables members of the community to determine if
there are any messages they can fetch on the community channel(chat).

`FirstMessageTimestamp` is advertised by admin for each community chat
through `CommunityDescription`. It assumes admin is online frequently
enough to capture the first channel message.

For existing communities admin determines first message timestamp by
finding oldest chat message in its local database.

task: status-im/status-desktop#6731
2022-09-09 08:59:39 +02:00
Richard Ramos 37d3f9f612
chore: hardcode optimism testnet for retrieving communities portal (#2810) 2022-09-06 14:07:22 -04:00
Patryk Osmaczko 7e25a6125f feat: introduce and distribute RequestToLeave community
closes: #2812
2022-08-26 11:25:33 +02:00
Pascal Precht 9b04633bb7 feat(communities): introduce `publish` flag in community manager APIs
This is so that we can control whether we want to publish the community
when it, or it's categories and channels, are created.

This is needed for the discord import so that we can create communities,
channels and categories without publishing the community and have it
show up in UIs too early.
2022-08-25 12:59:30 +02:00
Michal Iskierko e6a3f63ec7 feat: Add DeclinedRequestsToJoinForCommunity to API
Issue #6279
2022-08-22 13:43:26 +02:00
Pascal Precht eda6d10ce5 fix: adjust error codes for discord import
There are two types of errors "non-critical" (or "warning") and "critical".
These map to error codes `1` and `2` respectively.

The current error codes are a left-over of initial experimenting.
2022-08-08 19:37:19 +02:00
Mikhail Rogachev cd91b19737
feat: add optional inviteMessage to share-community request (#2776) 2022-08-08 13:49:39 +03:00
Pascal Precht 9c568c58cf feat: introduce messenger APIs to extract discord channels
As part of the new Discord <-> Status Community Import functionality,
we're adding an API that extracts all discord categories and channels
from a previously exported discord export file.

These APIs can be used in clients to show the user what categories and
channels will be imported later on.

There are two APIs:

1. `Messenger.ExtractDiscordCategoriesAndChannels(filesToimport
   []string) (*MessengerResponse, map[string]*discord.ImportError)`

   This takes a list of exported discord export (JSON) files (typically one per
   channel), reads them, and extracts the categories and channels into
   dedicated data structures (`[]DiscordChannel` and `[]DiscordCategory`)

   It also returns the oldest message timestamp found in all extracted
   channels.

   The API is synchronous and returns the extracted data as
   a `*MessengerResponse`. This allows to make the API available
   status-go's RPC interface.

   The error case is a `map[string]*discord.ImportError` where each key
   is a file path of a JSON file that we tried to extract data from, and
   the value a `discord.ImportError` which holds an error message and an
   error code, allowing for distinguishing between "critical" errors and
   "non-critical" errors.

2. `Messenger.RequestExtractDiscordCategoriesAndChannels(filesToImport
   []string)`

   This is the asynchronous counterpart to
   `ExtractDiscordCategoriesAndChannels`. The reason this API has been
   added is because discord servers can have a lot of message and
   channel data, which causes `ExtractDiscordCategoriesAndChannels` to
   block the thread for too long, making apps potentially feel like they
   are stuck.

   This API runs inside a go routine, eventually calls
   `ExtractDiscordCategoriesAndChannels`, and then emits a newly
   introduced `DiscordCategoriesAndChannelsExtractedSignal` that clients
   can react to.

   Failure of extraction has to be determined by the
   `discord.ImportErrors` emitted by the signal.

**A note about exported discord history files**

We expect users to export their discord histories via the
[DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter/wiki/GUI%2C-CLI-and-Formats-explained#exportguild)
tool. The tool allows to export the data in different formats, such as
JSON, HTML and CSV.

We expect users to have their data exported as JSON.

Closes: https://github.com/status-im/status-desktop/issues/6690
2022-08-04 14:34:23 +02:00
Parvesh Monu 60a49fc7d9
Timeout automatic status updates (#2757) 2022-08-03 04:38:01 +05:30