fix: add missing information

This commit is contained in:
Richard Ramos 2022-02-11 16:59:43 -04:00
parent 0f423e262d
commit f9b87c4ae1
2 changed files with 42 additions and 20 deletions

View File

@ -682,6 +682,10 @@ func (o *Community) Muted() bool {
return o.config.Muted return o.config.Muted
} }
func (o *Community) MemberIdentity() *ecdsa.PublicKey {
return o.config.MemberIdentity
}
// UpdateCommunityDescription will update the community to the new community description and return a list of changes // UpdateCommunityDescription will update the community to the new community description and return a list of changes
func (o *Community) UpdateCommunityDescription(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, rawMessage []byte) (*CommunityChanges, error) { func (o *Community) UpdateCommunityDescription(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, rawMessage []byte) (*CommunityChanges, error) {
o.mutex.Lock() o.mutex.Lock()

View File

@ -77,13 +77,20 @@ type Chat struct {
} }
type ChannelGroup struct { type ChannelGroup struct {
Type ChannelGroupType `json:"channelGroupType"` Type ChannelGroupType `json:"channelGroupType"`
Name string `json:"name"` Name string `json:"name"`
Images map[string]images.IdentityImage `json:"images"` Images map[string]images.IdentityImage `json:"images"`
Color string `json:"color"` Color string `json:"color"`
Chats map[string]*Chat `json:"chats"` Chats map[string]*Chat `json:"chats"`
Categories map[string]communities.CommunityCategory `json:"categories"` Categories map[string]communities.CommunityCategory `json:"categories"`
EnsName string `json:"ensName"` EnsName string `json:"ensName"`
Admin bool `json:"admin"`
Verified bool `json:"verified"`
Description string `json:"description"`
Permissions *protobuf.CommunityPermissions `json:"permissions"`
Members map[string]*protobuf.CommunityMember `json:"members"`
CanManageUsers bool `json:"canManageUsers"`
Muted bool `json:"muted"`
} }
func NewAPI(service *Service) *API { func NewAPI(service *Service) *API {
@ -109,13 +116,18 @@ func (api *API) GetChats(ctx context.Context) (map[string]ChannelGroup, error) {
result := make(map[string]ChannelGroup) result := make(map[string]ChannelGroup)
result[pubKey] = ChannelGroup{ result[pubKey] = ChannelGroup{
Type: Personal, Type: Personal,
Name: "", Name: "",
Images: make(map[string]images.IdentityImage), Images: make(map[string]images.IdentityImage),
Color: "", Color: "",
Chats: make(map[string]*Chat), Chats: make(map[string]*Chat),
Categories: make(map[string]communities.CommunityCategory), Categories: make(map[string]communities.CommunityCategory),
EnsName: "", // Not implemented yet in communities EnsName: "", // Not implemented yet in communities
Admin: true,
Verified: true,
Description: "",
Permissions: &protobuf.CommunityPermissions{},
Muted: false,
} }
for _, chat := range channels { for _, chat := range channels {
@ -132,12 +144,18 @@ func (api *API) GetChats(ctx context.Context) (map[string]ChannelGroup, error) {
for _, community := range joinedCommunities { for _, community := range joinedCommunities {
chGrp := ChannelGroup{ chGrp := ChannelGroup{
Type: Community, Type: Community,
Name: community.Name(), Name: community.Name(),
Color: community.Description().Identity.Color, Color: community.Description().Identity.Color,
Images: make(map[string]images.IdentityImage), Images: make(map[string]images.IdentityImage),
Chats: make(map[string]*Chat), Chats: make(map[string]*Chat),
Categories: make(map[string]communities.CommunityCategory), Categories: make(map[string]communities.CommunityCategory),
Admin: community.IsAdmin(),
Verified: community.Verified(),
Description: community.DescriptionText(),
Permissions: community.Description().Permissions,
CanManageUsers: community.CanManageUsers(community.MemberIdentity()),
Muted: community.Muted(),
} }
for t, i := range community.Description().Identity.Images { for t, i := range community.Description().Identity.Images {