Commit Graph

61 Commits

Author SHA1 Message Date
Mykhailo Prakhov eb437e9d8d
feat: kick all members after ownership change and auto-accept after sharing the address (#4187)
feat: kick all members after the ownership change and auto-accept after sharing the address
2023-10-31 15:20:40 +01:00
Patryk Osmaczko 345851c396 feat: ensure unique control node across devices
closes: status-im/status-desktop#11962
2023-10-22 21:50:41 +02:00
Patryk Osmaczko 0881d8cdb0 Add queue for processing community description & configurable control node 2023-10-17 21:00:24 +01:00
richΛrd ba5ed725ce
waku2: static shards (#3944)
- use protected topics for communities
- associate chats to pubsub topics and populate these depending if the chat belongs to a community or not
- mailserver functions should be aware of pubsub topics
- generate private key for pubsub topic protection when creating a community
- add shard cluster and index to communities
- setup shards for existing communities
- distribute pubsubtopic password
- fix: do not send the requests to join and cancel in the protected topic
- fix: undefined shard values for backward compatibility
- refactor: use shard message in protobuffers
2023-10-12 15:21:49 -04:00
Patryk Osmaczko 9d374bcadc chore: use lamport timestamp for communities
closes: status-im/status-desktop#11961
2023-10-03 21:45:28 +02:00
Mykhailo Prakhov db9adb631f
feat: share requests to join and revealed addresses with privileged roles (#3951)
- share requests to join with new privileged roles during reevaluating member role
- share requests to join with new members, joined the community as TOKEN_MASTER, ADMIN
- share requests to join revealed addresses to ADMINS and TOKEN_MASTERS
- refactor common test functionality to make them more predictable
- removed unused CommunityToken protobuf
2023-09-20 10:37:46 +02:00
Jonathan Rainville f7b342bb07
feat(shared_addresses): save own shared addresses in DB (#3950) 2023-08-29 14:56:30 -04:00
Andrea Maria Piana 8dd1b66d69 Always use protobufs by reference & generate handlers 2023-08-22 12:08:54 +01:00
Jonathan Rainville 3bf0bed78d
Fix pending join requests + API to get them (#3902)
Needed for https://github.com/status-im/status-desktop/issues/11851
2023-08-18 15:52:13 -04:00
Michal Iskierko 9d0acc2265 feat(OwnerToken): Owner token and master token deployment
Adding new smart contracts and generated go files.
Deploy token owner function and master token address getter.
Adding deployer and privilegesLevel columns to community_tokens table.
Passing addressFrom to API calls.

Issue #11250
2023-08-14 20:57:00 +02:00
Pascal Precht 4b07960fba feat: rehydrate community_tokens table upon account recovery
Closes https://github.com/status-im/status-desktop/issues/11188
2023-08-09 13:38:59 +02:00
Pascal Precht 688fb333a0 chore: don't expose `RevealedAccount`s on community description
Prior to this commit a control node would add the revealed addresses to
the member struct on the community description, which exposes all those
addresses to the public.

We don't want that. Revealed addresses are exclusively shared with
control nodes and should stay there (although, they might be privately
shared among token masters, see
https://github.com/status-im/status-desktop/issues/11610).

In this commit, we no longer add the revealed addresses to the community
description. The addresses are already stored in the requestToJoin
database table so we can take them from there if we need them.

Closes: https://github.com/status-im/status-desktop/issues/11573
2023-08-08 19:02:47 +02:00
Pascal Precht 248e4a7f24 refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.

Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.

This commit changes this behaviour such that:

1. EventSenders can make a decision (accept, reject), but merely forward
   their decision to the control node, which ultimately has to confirm
   it
2. EventSenders are no longer removing or adding members to and from
   communities
3. When an eventsender signaled a decision, the membership request will
   enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
   override that decision

This implementation is covered with a bunch of tests:

- Ensure that decision made by event sender is shared with other event
  senders
  - `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
  - `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
  confirmed decision by event senders
  - `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
  - `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
  event senders
  - `testEventSenderCannotOverrideRequestToJoinState()`

These test cases live in three test suites for different event sender
types respectively

- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`

In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).

Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.

This commit does not yet handle the case of event senders attempting to
kick and ban members.

Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-08 14:46:03 +02:00
Patryk Osmaczko 47c568fb08 refactor: improve wrapped community description naming 2023-08-02 20:57:19 +02:00
Patryk Osmaczko 9eaf229161 refactor: improve community functions naming 2023-08-02 19:59:16 +02:00
Pascal Precht 3d1b1bab57 feat: introduce messenger API to remove community tokens
This is to allow users to remove a community token if the deployment
transaction has been rejected.
2023-07-26 15:57:08 +02:00
Pascal Precht e8bac916ec !refactor: introduce `SaveCommunityToken()` and change `AddCommunityToken()`
**This is a breaking change!**

Prior to this commit we had `AddCommunityToken(token *communities,
croppedImage CroppedImage)` that we used to

1. add a `CommunityToken` to the user's database and
2. to create a `CommunityTokenMetadata` from it which is then added to
   the community's `CommunityDescription` and published to its members

However, I've then discovered that we need to separate these two things,
such that we can deploy a community token, then add it to the database
only for tracking purposes, **then** add it to the community description
(and propagate to members) once we know that the deploy tx indeed went
through.

To implement this, this commit introduces a new API
`SaveCommunityToken(token *communities.CommunityToken, croppedImage
CroppedImage)` which adds the token to the database only and doesn't
touch the community description.

The `AddCommunityToken` API is then changed that it's exclusively used
for adding an already saved `CommunityToken` to the community
description so it can be published to members. Hence, the signature is
now `AddCommunityToken(communityID string, chainID int, address
string)`, which makes this a breaking change.

Clients that used `AddCommunityToken()` before now need to ensure that
they first call `SaveCommunityToken()` as `AddCommunityToken()` will
fail otherwise.
2023-07-26 14:45:02 +02:00
Samuel Hawksby-Robinson d60beb2283 refactor to remove rekeyedAt and use group current key 2023-07-24 17:18:42 +01:00
Samuel Hawksby-Robinson a06984aeec Ensured time was a value and implemented explicit RekeyCommunity() 2023-07-24 17:18:42 +01:00
Samuel Hawksby-Robinson 03e28eea0d Implement correct getter and setter functionality for Communities 2023-07-24 17:18:42 +01:00
Samuel Hawksby-Robinson 243135d744 Rekey loop basics 2023-07-24 17:18:42 +01:00
Jonathan Rainville 12dc86fe1b
fix(persistence): fix get revealed accounts when isAirdropAddress is nil (#3780) 2023-07-19 15:23:00 -04:00
John Ngei cf2d72bfa8
Mute and Unmute community
* mute and unmute all community chats when community mute status changes

* unmute community when atleast one channel is unmuted

* fix: save community, extend the function to save muted state and mute duration
2023-07-19 15:14:42 +03:00
Mykhailo Prakhov 0919a87588
chore: community admin events (#3678)
chore: 
- add CommunityEventsMessage
- refactor community_admin_event to accept a list of events and patch a CommunityDescription
- save/read community events into/from database
- publish and handle community events message
- fixed admin category tests
- rename AdminEvent to Events or CommunityEvents
2023-07-18 17:06:12 +02:00
Jonathan Rainville 9674bc463f
feat(communities): add airdropAddress param to SharedAccounts (#3756)
Adds airdropAddress to the request to join params and a is_airdrop_address flag in the communities_requests_to_join_revealed_addresses table. 

This airdropAddress is used by the owner to know which address to use when airdropping
2023-07-14 13:33:47 -04:00
Michal Iskierko ff0628c23b feat(Collectibles): Handle ERC20 burn and mint
Modify API to handle also ERC20 tokens.
Modify community_tokens table - keep supply as string since string is easly convertible to bigint.BigInt.
Use bigint.BigInt for supply functions and fields.

Issue #11129
2023-07-12 10:41:17 +02:00
Michal Iskierko 6ec50d52aa feat(AssetsDeployment): Assets deployment
- Add ERC20 contract
- Add decimals field to community_tokens db table
- Adjusting API to handle assets deployment
- Add decimals field to CommunityTokenMetadata

Issue #10987
2023-06-29 16:10:05 +02:00
Pascal Precht b8b402da8d feat: store check channel permission responses
This commit adds new tables to the database and APIs in `Messenger` and
communities `Manager` to store `CheckChannelPermissionsResponse`s.

The responses are stored whenever channel permissions have been checked.

The reason we're doing this is so that clients can retrieve the last
known channel permission state before waiting for onchain checks to
finish.
2023-06-27 12:13:59 +02:00
Boris Melnik 1eb92a19a2
feat(communities): Adds muting interval to community (#3549) 2023-06-17 11:19:05 +03:00
Michal Iskierko ccde92377d feat(BurnCollectibles): Add burn collectibles functionality
Change smart contract with new API.
Update gas amount for deployment.
Add Burn() and EstimateBurn() functions.
Add RemainingSupply() functions.

Issue #10816
2023-06-15 15:38:19 +02:00
Mykhailo Prakhov e058b50a2e
feat: community admin permission functionality (#3569)
* feat: community admin implementation

* fix: code review fixes

* chore: request admin permissions in CheckPermissionToJoin, unit test fix
2023-06-14 10:15:46 -04:00
Pascal Precht 1a2ca21070 Add chainIds to revealed accounts in memberhsip requests
This commit does a few things:

- Adds a migration that adds chainids to communities_request_to_join_revealed_addresses
- Removes RevealedAddress in favor of RevealedAccount which is now a struct that contains the revealed address, as well as the signature and a list of chain IDs on which to check for user funds
- Changes the logic of sending requests to join a community, such that after creating address signatures, the user node will also check which of the addresses has funds on which networks for the community's token permissions, and add the chainds to the RevealedAccount
- Updates checkPermissionToJoin() such that only relevant chainids are used when checking user's funds. Chain IDs are retrieved from RevealedAccounts and matched against token permission criteria chain IDs
2023-06-12 10:49:29 +02:00
Michal Iskierko 4935848287 fix(GetAllCommunityTokens): Add GetAllCommunityTokens function
Issue #10254
2023-05-05 18:14:55 +02:00
Mohamed Javid 0eff61c57a
Community request to join changes for pending and declined states (#3387)
* Community request to join changes

* Fix read state for request to join notification

* Bring back deleted notification when updated with response

* Update Request timeout to 7 days

* Update VERSION
2023-04-21 14:48:47 +05:30
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 8a296407f3 fix(GetCommunityTokens): Change API call - use only communityId param
Fix #9725
2023-03-06 10:46:41 +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
Andrea Maria Piana c38ec00a2d Add community request to response when a response handled
In general, any time a piece of state is updated in the backend, that
should be propagated to the client through signals.

In this case, when a request was accepted, the client wasn't notified,
requiring them to re-fetch the accepted requests and causing
inconsistent state between status-go and client.
2023-02-07 13:17:19 +00:00
Pascal Precht b4bdfd3df6 Keep track of last seen magnetlink
This is to prevent processing magnetlinks if they haven't changed
2022-12-20 15:16:08 +01:00
Pascal Precht f5dfa58602 refactor(communities): better archive download handling
This commit makes a few changes to the community history archive
download routine to make it more robust:

1. Prior to this commit, even when there were no archives to be
   downloaded, we were still trying to extract messages from archive
   data.
2. Logs have been improved as they were sometimes showing confusing
   information
3. We now handle interruption of ongoing download + data import much
   better in case of multiple magnetlinks being processed in roughly the
   same time.
4. We now keep track of which archive has been successfully imported
   into the database. Without this, Status would consider any downloaded
   archives as "done" even though they haven't actually been imported
   into the database yet. This way Status should be able to pick up its
   work were it left of the last time, in case a user closes the app, or
   another magnetlink interrupts the ongoing process.
2022-12-13 16:13:15 +01: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 b2dce92f3f fix(Communities): correct query params order when updating community
settings

Turns out `UpdateCommunitySettings()` has never worked. Two parameters
where in the wrong order, cause the SQL statement to never find the row
it has to update.
2022-10-24 12:02:52 +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 c01ad05525 feat(common): add `ThirdPartyID` to `Message` and `protobuf.WakuMessage`
Usually, message IDs are generated by their payload and signature and
in receiving nodes calculated in based on the same data as well.

There's no ID attached to messages in-flight.

This turns out to be a bit of a problem for messages that are being
imported from third party systems like discord, as the conversion
and saving of such messages and handling of their possible assets and
attachments are done in separate steps, which changes the message
payloads after their IDs have been generated.

Hence, we're introducing a `ThirdPartyID` property to `common.Message`
and `protobuf.WakuMessage` so receiving nodes of such messages (via the
archive protocol primarily) can easily detect third party/imported
messages and give them special treatment.
2022-09-29 11:15:47 +02:00
Patryk Osmaczko 7e25a6125f feat: introduce and distribute RequestToLeave community
closes: #2812
2022-08-26 11:25:33 +02:00
Michal Iskierko e6a3f63ec7 feat: Add DeclinedRequestsToJoinForCommunity to API
Issue #6279
2022-08-22 13:43:26 +02:00
Pascal Precht 9d5bcc3c60 feat: sync `CommunitySettings` across paired devices
This commit introduces a new `clock` field in the
`communities_settings` table so that it can be leveraged for syncing
community settings across devices.

It alsoe exends existing `syncCommunity` APIs to generate
`SyncCommunitySettings` as well, avoiding sending additional sync messages
for community settings.

When editing communities however, we still sync community settings
explicitly are we aren't syncing the community itself in that case.
2022-06-16 12:45:05 +02:00
Pascal Precht 43d6305157 Handle history archive magnetlink messages
This introduces the ability for status notes to handle community
history archive magnetlinks. To make this work, a few things are needed:

1. A new database table has been introduced to store message archive
   hashes. This is necessary so status nodes can determine whether or
   not they need to download a certain archive
2. The messenger's `handleRetrievedMessages()` has been exteded to take
   magnetlink messages into account
3. New APIs were added to download torrent data given a magnetlink and
   also to extract messages from downloaded archives, which are then
   later fed to `handleRetrievedMessages`

Closes #2568
2022-05-10 11:27:31 +02:00