feat: introduce communities settings#2500
feat: introduce communities settings#25000x-r4bbit wants to merge 1 commit intostatus-im:developfrom
Conversation
Pull Request Checklist
|
Jenkins BuildsClick to see older builds (6)
|
multiaccounts/accounts/database.go
Outdated
| ) | ||
|
|
||
| communitiesSettings, err := db.GetCommunitiesSettings() | ||
| s.CommunitiesSettings = communitiesSettings |
There was a problem hiding this comment.
Since communities_settings live in a separate table, I'm explicitly querying/assigning it here.
Let me know if this should not happen here and whether we prefer a separate RPC API so clients can request that data.
| CommunityID string `json:"communityId"` | ||
| MessageArchiveFetchingEnabled bool `json:"messageArchiveFetchingEnabled"` | ||
| MessageArchiveSeedingEnabled bool `json:"messageArchiveSeedingEnabled"` | ||
| } |
There was a problem hiding this comment.
This might not be the proper place to put this type.
Eventually, we probably need a type for enabling/disabling community history archive support in the CLI as well. Might as well leverage this type for that, which is why I put it here.
Happy to put it somewhere else.
protocol/messenger_communities.go
Outdated
| CommunityID: communityID.String(), | ||
| MessageArchiveFetchingEnabled: true, | ||
| MessageArchiveSeedingEnabled: false, | ||
| } |
There was a problem hiding this comment.
These are the defaults when joining a community.
If could also introduce a GetDefaultCommunitySettings API if you prefer.
| ImageBx int `json:"imageBx"` | ||
| ImageBy int `json:"imageBy"` | ||
| MessageArchiveSeedingEnabled bool `json:"messageArchiveSeedingEnabled,omitempty"` | ||
| MessageArchiveFetchingEnabled bool `json:"messageArchiveFetchingEnabled,omitempty"` |
There was a problem hiding this comment.
I made those two omitempty so we can potentially put these changes into production without having the need for desktop and/or mobile to do anything in particular.
There's a pending PR for a protocol spec addition that eventually needs these changes: status-im/specs#164 |
This commit introduces new communities settings that are needed for the upcoming Community History Archive support. Namely, we need to persist whether community owners will seed message history archives and whether community members are interested in fetching such archives. The settings are defined as follows: 1. `community_id` - The id of the community the settings belong to 2. `message_archive_seeding_enabled` - Whether message history archives will be created and seeded for this community 3. `message_archive_fetching_enabled` - Whether message history archives will fetched for this community The data is persisted in a newly introduced `communities_settings` table. Furthermore, the RPC API that returns `Settings` for the logged in account will now include a `communities-settings` field of type: `[]CommunitySettings`. The community settings in the database will be added, updated an deleted depending whether the user joins, leaves or edits the community in question. Closes status-im#2495
|
The linting error caused in this PR: https://ci.status.im/blue/organizations/jenkins/status-go%2Fprs%2Ftests/detail/PR-2500/4/pipeline#step-60-log-3 seems to be unrelated to my changes. |
|
As discussed offline with @cammellos, introduction of I'll give that a spin, so please don't merge this yet. |
| return description, nil | ||
| } | ||
|
|
||
| func (c *CreateCommunity) ToCommunitySettings(publicKey string) (params.CommunitySettings, error) { |
There was a problem hiding this comment.
Is an error expected? if not, it can be removed from the return parameters
There was a problem hiding this comment.
It's not, wanted to stay consistent. But happy to change this!
| return "", err | ||
| } | ||
|
|
||
| func (db *Database) SaveCommunitySettings(communitySettings params.CommunitySettings) error { |
There was a problem hiding this comment.
In protocol/communities/persistence.go live all the functions related to communities CRUD operations. What do you think of having these community settings functions live there too?
There was a problem hiding this comment.
Happy to move it over!
Main reason I put them here was because I consider them more "settings" related to the account. Like.. we could also call the entire thing "node_settings" if we want (once we get to actually supporting all the settings like throttling etc). In that sense it wouldn't necessarily be community specific anymore.
But yea, I totally see where you're coming from, so I'll move it over for now. We can still migrate it to somewhere else once this stuff gets broader responsibility.
| @@ -0,0 +1,5 @@ | |||
| CREATE TABLE communities_settings ( | |||
| community_id TEXT PRIMARY KEY ON CONFLICT REPLACE, | |||
There was a problem hiding this comment.
In protocol/migrations/sqlite/1605075346_add_communities.up.sql the community_id is defined as
id BLOB NOT NULL PRIMARY KEY ON CONFLICT REPLACE. Consider using the same data type (blob)
| if err != nil { | ||
| return err | ||
| } | ||
| return nil |
There was a problem hiding this comment.
| if err != nil { | |
| return err | |
| } | |
| return nil | |
| return err |
| communitiesSettings, err := db.GetCommunitiesSettings() | ||
| s.CommunitiesSettings = communitiesSettings |
There was a problem hiding this comment.
If there's an err, it might end up being overwritten by a succesful db.getCommunitiesSetting() response
| communitiesSettings, err := db.GetCommunitiesSettings() | |
| s.CommunitiesSettings = communitiesSettings | |
| if err != nil { | |
| return s, err | |
| } | |
| communitiesSettings, err := db.GetCommunitiesSettings() | |
| s.CommunitiesSettings = communitiesSettings |
|
Closing in favour of #2574 |
This commit introduces new communities settings that are needed for the
upcoming Community History Archive support.
Namely, we need to persist whether community owners will seed message
history archives and whether community members are interested in
fetching such archives.
The settings are defined as follows:
community_id- The id of the community the settings belong tomessage_archive_seeding_enabled- Whether message history archiveswill be created and seeded for this community
message_archive_fetching_enabled- Whether message history archiveswill fetched for this community
The data is persisted in a newly introduced
communities_settingstable.
Furthermore, the RPC API that returns
Settingsfor the logged inaccount will now include a
communities-settingsfield of type:[]CommunitySettings.The community settings in the database will be added, updated an deleted
depending whether the user joins, leaves or edits the community in
question.
Tasks
Closes #2495