feat: add intro/outro message to communities

This commit is contained in:
Patryk Osmaczko 2022-05-24 21:20:13 +02:00 committed by osmaczko
parent 888dd0e3e7
commit ee7025a573
6 changed files with 177 additions and 123 deletions

View File

@ -94,6 +94,8 @@ func (o *Community) MarshalPublicAPIJSON() ([]byte, error) {
Categories map[string]CommunityCategory `json:"categories"`
Name string `json:"name"`
Description string `json:"description"`
IntroMessage string `json:"introMessage"`
OutroMessage string `json:"outroMessage"`
Images map[string]images.IdentityImage `json:"images"`
Color string `json:"color"`
MembersCount int `json:"membersCount"`
@ -136,6 +138,9 @@ func (o *Community) MarshalPublicAPIJSON() ([]byte, error) {
}
communityItem.MembersCount = len(o.config.CommunityDescription.Members)
communityItem.Link = fmt.Sprintf("https://join.status.im/c/0x%x", o.ID())
communityItem.IntroMessage = o.config.CommunityDescription.IntroMessage
communityItem.OutroMessage = o.config.CommunityDescription.OutroMessage
if o.config.CommunityDescription.Identity != nil {
communityItem.Name = o.Name()
communityItem.Color = o.config.CommunityDescription.Identity.Color
@ -172,6 +177,8 @@ func (o *Community) MarshalJSON() ([]byte, error) {
RequestedAccessAt int `json:"requestedAccessAt"`
Name string `json:"name"`
Description string `json:"description"`
IntroMessage string `json:"introMessage"`
OutroMessage string `json:"outroMessage"`
Chats map[string]CommunityChat `json:"chats"`
Categories map[string]CommunityCategory `json:"categories"`
Images map[string]images.IdentityImage `json:"images"`
@ -229,6 +236,9 @@ func (o *Community) MarshalJSON() ([]byte, error) {
}
communityItem.Members = o.config.CommunityDescription.Members
communityItem.Permissions = o.config.CommunityDescription.Permissions
communityItem.IntroMessage = o.config.CommunityDescription.IntroMessage
communityItem.OutroMessage = o.config.CommunityDescription.OutroMessage
if o.config.CommunityDescription.Identity != nil {
communityItem.Name = o.Name()
communityItem.Color = o.config.CommunityDescription.Identity.Color
@ -273,6 +283,24 @@ func (o *Community) DescriptionText() string {
return ""
}
func (o *Community) IntroMessage() string {
if o != nil &&
o.config != nil &&
o.config.CommunityDescription != nil {
return o.config.CommunityDescription.IntroMessage
}
return ""
}
func (o *Community) OutroMessage() string {
if o != nil &&
o.config != nil &&
o.config.CommunityDescription != nil {
return o.config.CommunityDescription.OutroMessage
}
return ""
}
func (o *Community) MembersCount() int {
if o != nil &&
o.config != nil &&
@ -684,6 +712,8 @@ func (o *Community) Edit(description *protobuf.CommunityDescription) {
o.config.CommunityDescription.Identity.Color = description.Identity.Color
o.config.CommunityDescription.Identity.Emoji = description.Identity.Emoji
o.config.CommunityDescription.Identity.Images = description.Identity.Images
o.config.CommunityDescription.IntroMessage = description.IntroMessage
o.config.CommunityDescription.OutroMessage = description.OutroMessage
if o.config.CommunityDescription.AdminSettings == nil {
o.config.CommunityDescription.AdminSettings = &protobuf.CommunityAdminSettings{}
}

View File

@ -247,6 +247,8 @@ type CommunityDescription struct {
Categories map[string]*CommunityCategory `protobuf:"bytes,8,rep,name=categories,proto3" json:"categories,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
ArchiveMagnetlinkClock uint64 `protobuf:"varint,9,opt,name=archive_magnetlink_clock,json=archiveMagnetlinkClock,proto3" json:"archive_magnetlink_clock,omitempty"`
AdminSettings *CommunityAdminSettings `protobuf:"bytes,10,opt,name=admin_settings,json=adminSettings,proto3" json:"admin_settings,omitempty"`
IntroMessage string `protobuf:"bytes,11,opt,name=intro_message,json=introMessage,proto3" json:"intro_message,omitempty"`
OutroMessage string `protobuf:"bytes,12,opt,name=outro_message,json=outroMessage,proto3" json:"outro_message,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -340,6 +342,20 @@ func (m *CommunityDescription) GetAdminSettings() *CommunityAdminSettings {
return nil
}
func (m *CommunityDescription) GetIntroMessage() string {
if m != nil {
return m.IntroMessage
}
return ""
}
func (m *CommunityDescription) GetOutroMessage() string {
if m != nil {
return m.OutroMessage
}
return ""
}
type CommunityAdminSettings struct {
PinMessageAllMembersEnabled bool `protobuf:"varint,1,opt,name=pin_message_all_members_enabled,json=pinMessageAllMembersEnabled,proto3" json:"pin_message_all_members_enabled,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@ -1079,84 +1095,86 @@ func init() {
}
var fileDescriptor_f937943d74c1cd8b = []byte{
// 1261 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x6f, 0x1b, 0x37,
0x13, 0xce, 0xea, 0xcb, 0xd2, 0xc8, 0x76, 0x64, 0x26, 0x71, 0x36, 0xce, 0x9b, 0x58, 0x59, 0xbc,
0x05, 0x14, 0x14, 0x55, 0x10, 0x07, 0x05, 0x82, 0x7e, 0x24, 0x51, 0x1c, 0x21, 0x55, 0x63, 0x4b,
0x09, 0x65, 0x37, 0x6d, 0x0e, 0x5d, 0x50, 0x5a, 0x5a, 0x26, 0xbc, 0xcb, 0x55, 0x97, 0x94, 0x51,
0xf5, 0xd0, 0x5b, 0x81, 0xfe, 0x84, 0x02, 0x05, 0x7a, 0x29, 0xd0, 0x3f, 0xd2, 0x7b, 0xef, 0xbd,
0xf5, 0xa7, 0x14, 0x24, 0x77, 0x57, 0x2b, 0x5b, 0x72, 0x02, 0x04, 0x3d, 0x2d, 0x87, 0x9c, 0x79,
0x38, 0xf3, 0xcc, 0x70, 0x66, 0x61, 0x63, 0x18, 0x06, 0xc1, 0x84, 0x33, 0xc9, 0xa8, 0x68, 0x8e,
0xa3, 0x50, 0x86, 0xa8, 0xac, 0x3f, 0x83, 0xc9, 0xd1, 0xd6, 0x95, 0xe1, 0x31, 0x91, 0x2e, 0xf3,
0x28, 0x97, 0x4c, 0x4e, 0xcd, 0xb1, 0x73, 0x0a, 0xc5, 0xe7, 0x11, 0xe1, 0x12, 0xdd, 0x81, 0xd5,
0xc4, 0x78, 0xea, 0x32, 0xcf, 0xb6, 0xea, 0x56, 0x63, 0x15,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0x00,
// 1288 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcd, 0x6e, 0xdb, 0x46,
0x10, 0x0e, 0xf5, 0x67, 0x69, 0x24, 0x39, 0xf2, 0x26, 0x71, 0x18, 0xa7, 0x89, 0x15, 0xb6, 0x05,
0x14, 0x14, 0x55, 0x10, 0x07, 0x05, 0x82, 0xfe, 0x24, 0x51, 0x1c, 0x21, 0x55, 0x63, 0x4b, 0xc9,
0xca, 0x6e, 0xda, 0x1c, 0x4a, 0x50, 0xe2, 0x5a, 0x5e, 0x98, 0x5c, 0xaa, 0xdc, 0x95, 0x51, 0xf5,
0xd0, 0x5b, 0x81, 0x3e, 0x42, 0x81, 0x1e, 0x0b, 0xf4, 0x45, 0x7a, 0xef, 0xbd, 0xb7, 0x1e, 0xfb,
0x18, 0xc5, 0xee, 0x92, 0x14, 0x25, 0x4b, 0x8e, 0x81, 0xa0, 0x27, 0xee, 0xcc, 0xce, 0xcc, 0xce,
0x7c, 0xf3, 0x47, 0xd8, 0x18, 0x06, 0xbe, 0x3f, 0x61, 0x54, 0x50, 0xc2, 0x9b, 0xe3, 0x30, 0x10,
0x01, 0x2a, 0xaa, 0xcf, 0x60, 0x72, 0xb4, 0x75, 0x65, 0x78, 0xec, 0x08, 0x9b, 0xba, 0x84, 0x09,
0x2a, 0xa6, 0xfa, 0xda, 0x3a, 0x85, 0xfc, 0xf3, 0xd0, 0x61, 0x02, 0xdd, 0x81, 0x4a, 0xac, 0x3c,
0xb5, 0xa9, 0x6b, 0x1a, 0x75, 0xa3, 0x51, 0xc1, 0xe5, 0x84, 0xd7, 0x71, 0xd1, 0x4d, 0x28, 0xf9,
0xc4, 0x1f, 0x90, 0x50, 0xde, 0x67, 0xd4, 0x7d, 0x51, 0x33, 0x3a, 0x2e, 0xba, 0x0e, 0x6b, 0x91,
0x7d, 0x33, 0x5b, 0x37, 0x1a, 0x25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0x33, 0x5a, 0x87, 0x8c, 0x08, 0x94, 0x9b, 0x39, 0x9c, 0x11, 0x01, 0xb2, 0x64, 0x7d,
0x30, 0x41, 0x98, 0x38, 0x50, 0x01, 0xe4, 0xea, 0xd9, 0x46, 0x05, 0xcf, 0xf1, 0xac, 0xdf, 0x0d,
0x40, 0x67, 0x1d, 0x38, 0xe7, 0xe1, 0x27, 0x50, 0xf4, 0x23, 0xf7, 0xa2, 0xba, 0x48, 0x4d, 0xc9,
0xd5, 0xa1, 0xe0, 0x44, 0x0b, 0xdd, 0x97, 0x16, 0x94, 0x8c, 0xfc, 0x95, 0x91, 0x73, 0xf6, 0xda,
0x52, 0x0b, 0x38, 0x11, 0xb3, 0xfe, 0x34, 0x60, 0xfb, 0xac, 0xed, 0x0e, 0x73, 0xc9, 0x0f, 0x17,
0xc0, 0xea, 0xdd, 0x5d, 0xde, 0x84, 0x42, 0x70, 0x74, 0xc4, 0x89, 0x88, 0xd0, 0x8d, 0x28, 0x99,
0x05, 0x4e, 0x7f, 0x24, 0xd1, 0x1f, 0xb9, 0x3a, 0x2f, 0xe6, 0x3f, 0x97, 0xe4, 0xdf, 0xfa, 0xcb,
0x80, 0xeb, 0x2b, 0xa2, 0x40, 0x2f, 0xa0, 0x18, 0xfd, 0xa0, 0xc4, 0xcb, 0xe7, 0xde, 0x79, 0x3e,
0x2a, 0xa5, 0x66, 0x44, 0x44, 0x7b, 0x28, 0x31, 0xb0, 0x75, 0x04, 0xd5, 0xb9, 0xab, 0x25, 0x63,
0xfd, 0xf1, 0xfc, 0x58, 0xbf, 0xfb, 0xd6, 0xc7, 0x12, 0x54, 0x66, 0x63, 0xfe, 0x69, 0xf5, 0x4d,
0xb9, 0x79, 0xef, 0xb3, 0x58, 0x73, 0x50, 0x50, 0xa7, 0x07, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff,
0x6b, 0x01, 0x17, 0xd0, 0x3d, 0x0d, 0x00, 0x00,
}

View File

@ -45,6 +45,8 @@ message CommunityDescription {
map<string,CommunityCategory> categories = 8;
uint64 archive_magnetlink_clock = 9;
CommunityAdminSettings admin_settings = 10;
string intro_message = 11;
string outro_message = 12;
}
message CommunityAdminSettings {

View File

@ -13,12 +13,23 @@ var (
ErrCreateCommunityInvalidName = errors.New("create-community: invalid name")
ErrCreateCommunityInvalidColor = errors.New("create-community: invalid color")
ErrCreateCommunityInvalidDescription = errors.New("create-community: invalid description")
ErrCreateCommunityInvalidIntroMessage = errors.New("create-community: invalid intro message")
ErrCreateCommunityInvalidOutroMessage = errors.New("create-community: invalid outro message")
ErrCreateCommunityInvalidMembership = errors.New("create-community: invalid membership")
)
const (
maxNameLength = 30
maxDescriptionLength = 140
maxIntroMessageLength = 1400
maxOutroMessageLength = 80
)
type CreateCommunity struct {
Name string `json:"name"`
Description string `json:"description"`
IntroMessage string `json:"introMessage,omitempty"`
OutroMessage string `json:"outroMessage,omitempty"`
Color string `json:"color"`
Emoji string `json:"emoji"`
Membership protobuf.CommunityPermissions_Access `json:"membership"`
@ -42,14 +53,22 @@ func adaptIdentityImageToProtobuf(img *userimages.IdentityImage) *protobuf.Ident
}
func (c *CreateCommunity) Validate() error {
if c.Name == "" {
if c.Name == "" || len(c.Name) > maxNameLength {
return ErrCreateCommunityInvalidName
}
if c.Description == "" {
if c.Description == "" || len(c.Description) > maxDescriptionLength {
return ErrCreateCommunityInvalidDescription
}
if len(c.IntroMessage) > maxIntroMessageLength {
return ErrCreateCommunityInvalidIntroMessage
}
if len(c.OutroMessage) > maxOutroMessageLength {
return ErrCreateCommunityInvalidOutroMessage
}
if c.Membership == protobuf.CommunityPermissions_UNKNOWN_ACCESS {
return ErrCreateCommunityInvalidMembership
}
@ -102,6 +121,8 @@ func (c *CreateCommunity) ToCommunityDescription() (*protobuf.CommunityDescripti
AdminSettings: &protobuf.CommunityAdminSettings{
PinMessageAllMembersEnabled: c.PinMessageAllMembersEnabled,
},
IntroMessage: c.IntroMessage,
OutroMessage: c.OutroMessage,
}
return description, nil
}

View File

@ -4,16 +4,10 @@ import (
"errors"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/protobuf"
)
var (
ErrEditCommunityInvalidID = errors.New("edit-community: invalid id")
ErrEditCommunityInvalidName = errors.New("edit-community: invalid name")
ErrEditCommunityInvalidColor = errors.New("edit-community: invalid color")
ErrEditCommunityInvalidDescription = errors.New("edit-community: invalid description")
ErrEditCommunityInvalidMembership = errors.New("edit-community: invalid membership")
)
type EditCommunity struct {
@ -22,26 +16,9 @@ type EditCommunity struct {
}
func (u *EditCommunity) Validate() error {
if len(u.CommunityID) == 0 {
return ErrEditCommunityInvalidID
}
if u.Name == "" {
return ErrEditCommunityInvalidName
}
if u.Description == "" {
return ErrEditCommunityInvalidDescription
}
if u.Membership == protobuf.CommunityPermissions_UNKNOWN_ACCESS {
return ErrEditCommunityInvalidMembership
}
if u.Color == "" {
return ErrEditCommunityInvalidColor
}
return nil
return u.CreateCommunity.Validate()
}

View File

@ -87,6 +87,8 @@ type ChannelGroup struct {
Admin bool `json:"admin"`
Verified bool `json:"verified"`
Description string `json:"description"`
IntroMessage string `json:"introMessage"`
OutroMessage string `json:"outroMessage"`
Permissions *protobuf.CommunityPermissions `json:"permissions"`
Members map[string]*protobuf.CommunityMember `json:"members"`
CanManageUsers bool `json:"canManageUsers"`
@ -126,6 +128,8 @@ func (api *API) GetChats(ctx context.Context) (map[string]ChannelGroup, error) {
Admin: true,
Verified: true,
Description: "",
IntroMessage: "",
OutroMessage: "",
Permissions: &protobuf.CommunityPermissions{},
Muted: false,
}
@ -153,6 +157,8 @@ func (api *API) GetChats(ctx context.Context) (map[string]ChannelGroup, error) {
Admin: community.IsAdmin(),
Verified: community.Verified(),
Description: community.DescriptionText(),
IntroMessage: community.IntroMessage(),
OutroMessage: community.OutroMessage(),
Permissions: community.Description().Permissions,
Members: community.Description().Members,
CanManageUsers: community.CanManageUsers(community.MemberIdentity()),