2021-08-06 15:40:23 +00:00
|
|
|
package communities
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
|
|
)
|
|
|
|
|
2023-08-18 11:39:59 +00:00
|
|
|
func (o *Community) ToSyncInstallationCommunityProtobuf(clock uint64, communitySettings *CommunitySettings) (*protobuf.SyncInstallationCommunity, error) {
|
2023-07-10 15:35:15 +00:00
|
|
|
wrappedCommunity, err := o.ToProtocolMessageBytes()
|
2021-08-06 15:40:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var rtjs []*protobuf.SyncCommunityRequestsToJoin
|
|
|
|
reqs := o.RequestsToJoin()
|
|
|
|
for _, req := range reqs {
|
|
|
|
rtjs = append(rtjs, req.ToSyncProtobuf())
|
|
|
|
}
|
|
|
|
|
2022-06-01 07:55:48 +00:00
|
|
|
settings := &protobuf.SyncCommunitySettings{
|
|
|
|
Clock: clock,
|
|
|
|
CommunityId: o.IDString(),
|
|
|
|
HistoryArchiveSupportEnabled: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
if communitySettings != nil {
|
|
|
|
settings.HistoryArchiveSupportEnabled = communitySettings.HistoryArchiveSupportEnabled
|
|
|
|
}
|
|
|
|
|
2023-08-18 11:39:59 +00:00
|
|
|
return &protobuf.SyncInstallationCommunity{
|
2021-08-06 15:40:23 +00:00
|
|
|
Clock: clock,
|
|
|
|
Id: o.ID(),
|
2023-07-10 15:35:15 +00:00
|
|
|
Description: wrappedCommunity,
|
2021-08-06 15:40:23 +00:00
|
|
|
Joined: o.Joined(),
|
|
|
|
Verified: o.Verified(),
|
|
|
|
Muted: o.Muted(),
|
|
|
|
RequestsToJoin: rtjs,
|
2022-06-01 07:55:48 +00:00
|
|
|
Settings: settings,
|
2021-08-06 15:40:23 +00:00
|
|
|
}, nil
|
|
|
|
}
|