Samuel Hawksby-Robinson 89251e8416
Sync Communities (#2253)
* Added community sync protobuf

* Updated community sync send logic

* Integrated syncCommunity handling

* Added synced_at field and tidied up some other logic

* persistence testing

* Added testing and join functionality

* Fixed issue with empty scan params

* Finshed persistence tests for new db funcs

* Midway debug of description not persisting after sync

* Resolved final issues and tidied up

* Polish

* delint

* Fix error not handled on SetPrivateKey

* fix infinite loop, again

* Added muted option and test fix

* Added Muted to syncing functions, not just in persistence

* Fix bug introduced with Muted property

* Added a couple of notes for future devs

* Added most of the sync RequestToJoin functionality

Tests need to be completed and tests are giving some errors

* Finished tests for getJoinedAndPending

* Added note

* Resolving lint

* Fix of protobuf gen bug

* Fixes to community sync tests

* Fixes to test

* Continued fix of e2e

* Final fix to e2e testing

* Updated migration position

* resolve missing import

* Apparently the linter spellchecks

* Fix bug from  #2276 merge

* Bug fix for leaving quirkiness

* Addressed superfluous MessengerResponse field

* Addressed feedback

* VERSION bump
2021-08-06 16:40:23 +01:00

37 lines
786 B
Go

package communities
import (
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/protocol/protobuf"
)
func (o *Community) ToSyncCommunityProtobuf(clock uint64) (*protobuf.SyncCommunity, error) {
var pkb []byte
pk := o.PrivateKey()
if pk != nil {
pkb = crypto.FromECDSA(pk)
}
md, err := o.ToBytes()
if err != nil {
return nil, err
}
var rtjs []*protobuf.SyncCommunityRequestsToJoin
reqs := o.RequestsToJoin()
for _, req := range reqs {
rtjs = append(rtjs, req.ToSyncProtobuf())
}
return &protobuf.SyncCommunity{
Clock: clock,
Id: o.ID(),
PrivateKey: pkb,
Description: md,
Joined: o.Joined(),
Verified: o.Verified(),
Muted: o.Muted(),
RequestsToJoin: rtjs,
}, nil
}