Mikhail Rogachev 631962ce88
feat: add api to remove private key (#3772)
* feat: add api to remove private key and separete owner from private key ownership

For https://github.com/status-im/status-desktop/issues/11475

* feat: introduce IsControlNode for Community

* feat: remove community private key from syncing

* feat: add IsControlNode flag to Community json serialisation

* Update protocol/protobuf/pairing.proto

Co-authored-by: Jonathan Rainville <rainville.jonathan@gmail.com>

---------

Co-authored-by: Jonathan Rainville <rainville.jonathan@gmail.com>
2023-07-21 13:41:26 +04:00

40 lines
989 B
Go

package communities
import (
"github.com/status-im/status-go/protocol/protobuf"
)
func (o *Community) ToSyncCommunityProtobuf(clock uint64, communitySettings *CommunitySettings) (*protobuf.SyncCommunity, error) {
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())
}
settings := &protobuf.SyncCommunitySettings{
Clock: clock,
CommunityId: o.IDString(),
HistoryArchiveSupportEnabled: true,
}
if communitySettings != nil {
settings.HistoryArchiveSupportEnabled = communitySettings.HistoryArchiveSupportEnabled
}
return &protobuf.SyncCommunity{
Clock: clock,
Id: o.ID(),
Description: md,
Joined: o.Joined(),
Verified: o.Verified(),
Muted: o.Muted(),
RequestsToJoin: rtjs,
Settings: settings,
}, nil
}