Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateCommunityDescription(desc *protobuf.CommunityDescription) error
- type Community
- func (o *Community) BanUserFromCommunity(pk *ecdsa.PublicKey) (*protobuf.CommunityDescription, error)
- func (o *Community) CanManageUsers(pk *ecdsa.PublicKey) bool
- func (o *Community) CanManageUsersPublicKeys() ([]*ecdsa.PublicKey, error)
- func (o *Community) CanPost(pk *ecdsa.PublicKey, chatID string, grantBytes []byte) (bool, error)
- func (o *Community) CanRequestAccess(pk *ecdsa.PublicKey) bool
- func (o *Community) Chats() map[string]*protobuf.CommunityChat
- func (o *Community) Clock() uint64
- func (o *Community) CreateChat(chatID string, chat *protobuf.CommunityChat) (*CommunityChanges, error)
- func (o *Community) DeleteChat(chatID string) (*protobuf.CommunityDescription, error)
- func (o *Community) Description() string
- func (o *Community) Edit(description *protobuf.CommunityDescription)
- func (o *Community) HasMember(pk *ecdsa.PublicKey) bool
- func (o *Community) ID() types.HexBytes
- func (o *Community) IDString() string
- func (o *Community) InvitationOnly() bool
- func (o *Community) InviteUserToChat(pk *ecdsa.PublicKey, chatID string) (*protobuf.CommunityInvitation, error)
- func (o *Community) InviteUserToOrg(pk *ecdsa.PublicKey) (*protobuf.CommunityInvitation, error)
- func (o *Community) IsAdmin() bool
- func (o *Community) IsBanned(pk *ecdsa.PublicKey) bool
- func (o *Community) IsMemberAdmin(publicKey *ecdsa.PublicKey) bool
- func (o *Community) IsMemberInChat(pk *ecdsa.PublicKey, chatID string) bool
- func (o *Community) Join()
- func (o *Community) Joined() bool
- func (o *Community) Leave()
- func (o *Community) MarshalJSON() ([]byte, error)
- func (o *Community) MarshaledDescription() ([]byte, error)
- func (o *Community) MembersCount() int
- func (o *Community) Name() string
- func (o *Community) OnRequest() bool
- func (o *Community) PrivateKey() *ecdsa.PrivateKey
- func (o *Community) PublicKey() *ecdsa.PublicKey
- func (o *Community) RemoveUserFromChat(pk *ecdsa.PublicKey, chatID string) (*protobuf.CommunityDescription, error)
- func (o *Community) RemoveUserFromOrg(pk *ecdsa.PublicKey) (*protobuf.CommunityDescription, error)
- func (o *Community) RequestedToJoinAt() uint64
- func (o *Community) ToBytes() ([]byte, error)
- func (o *Community) UpdateCommunityDescription(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, ...) (*CommunityChanges, error)
- func (o *Community) ValidateRequestToJoin(signer *ecdsa.PublicKey, request *protobuf.CommunityRequestToJoin) error
- func (o *Community) VerifyGrantSignature(data []byte) (*protobuf.Grant, error)
- type CommunityChanges
- type CommunityChat
- type CommunityChatChanges
- type CommunityResponse
- type Config
- type Manager
- func (m *Manager) AcceptRequestToJoin(request *requests.AcceptRequestToJoinCommunity) (*Community, error)
- func (m *Manager) All() ([]*Community, error)
- func (m *Manager) BanUserFromCommunity(request *requests.BanUserFromCommunity) (*Community, error)
- func (m *Manager) CanPost(pk *ecdsa.PublicKey, communityID string, chatID string, grant []byte) (bool, error)
- func (m *Manager) CreateChat(communityID types.HexBytes, chat *protobuf.CommunityChat) (*Community, *CommunityChanges, error)
- func (m *Manager) CreateCommunity(request *requests.CreateCommunity) (*Community, error)
- func (m *Manager) Created() ([]*Community, error)
- func (m *Manager) DeclineRequestToJoin(request *requests.DeclineRequestToJoinCommunity) error
- func (m *Manager) EditCommunity(request *requests.EditCommunity) (*Community, error)
- func (m *Manager) ExportCommunity(id types.HexBytes) (*ecdsa.PrivateKey, error)
- func (m *Manager) GetByID(id []byte) (*Community, error)
- func (m *Manager) GetByIDString(idString string) (*Community, error)
- func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, ...) (*CommunityResponse, error)
- func (m *Manager) HandleCommunityInvitation(signer *ecdsa.PublicKey, invitation *protobuf.CommunityInvitation, ...) (*CommunityResponse, error)
- func (m *Manager) HandleCommunityRequestToJoin(signer *ecdsa.PublicKey, request *protobuf.CommunityRequestToJoin) (*RequestToJoin, error)
- func (m *Manager) HandleWrappedCommunityDescriptionMessage(payload []byte) (*CommunityResponse, error)
- func (m *Manager) ImportCommunity(key *ecdsa.PrivateKey) (*Community, error)
- func (m *Manager) InviteUsersToCommunity(communityID types.HexBytes, pks []*ecdsa.PublicKey) (*Community, error)
- func (m *Manager) JoinCommunity(id types.HexBytes) (*Community, error)
- func (m *Manager) Joined() ([]*Community, error)
- func (m *Manager) LeaveCommunity(id types.HexBytes) (*Community, error)
- func (m *Manager) PendingRequestsToJoinForCommunity(id types.HexBytes) ([]*RequestToJoin, error)
- func (m *Manager) PendingRequestsToJoinForUser(pk *ecdsa.PublicKey) ([]*RequestToJoin, error)
- func (m *Manager) RemoveUserFromCommunity(id types.HexBytes, pk *ecdsa.PublicKey) (*Community, error)
- func (m *Manager) RequestToJoin(requester *ecdsa.PublicKey, request *requests.RequestToJoinCommunity) (*Community, *RequestToJoin, error)
- func (m *Manager) Start() error
- func (m *Manager) Stop() error
- func (m *Manager) Subscribe() chan *Subscription
- type Persistence
- func (p *Persistence) AllCommunities(memberIdentity *ecdsa.PublicKey) ([]*Community, error)
- func (p *Persistence) CreatedCommunities(memberIdentity *ecdsa.PublicKey) ([]*Community, error)
- func (p *Persistence) GetByID(memberIdentity *ecdsa.PublicKey, id []byte) (*Community, error)
- func (p *Persistence) GetRequestToJoin(id []byte) (*RequestToJoin, error)
- func (p *Persistence) HasPendingRequestsToJoinForUserAndCommunity(userPk string, communityID []byte) (bool, error)
- func (p *Persistence) JoinedCommunities(memberIdentity *ecdsa.PublicKey) ([]*Community, error)
- func (p *Persistence) PendingRequestsToJoinForCommunity(id []byte) ([]*RequestToJoin, error)
- func (p *Persistence) PendingRequestsToJoinForUser(pk string) ([]*RequestToJoin, error)
- func (p *Persistence) SaveCommunity(community *Community) error
- func (p *Persistence) SaveRequestToJoin(request *RequestToJoin) (err error)
- func (p *Persistence) SetRequestToJoinState(pk string, communityID []byte, state uint) error
- type RequestToJoin
- type Subscription
Constants ¶
View Source
const ( RequestToJoinStatePending uint = iota + 1 RequestToJoinStateDeclined RequestToJoinStateAccepted )
Variables ¶
View Source
var ErrAlreadyMember = errors.New("already a member")
View Source
var ErrCantRequestAccess = errors.New("can't request access")
View Source
var ErrChatAlreadyExists = errors.New("chat already exists")
View Source
var ErrChatNotFound = errors.New("chat not found")
View Source
var ErrInvalidCommunityDescription = errors.New("invalid community description")
View Source
var ErrInvalidCommunityDescriptionMemberInChatButNotInOrg = errors.New("invalid community description member in chat but not in org")
View Source
var ErrInvalidCommunityDescriptionNoChatPermissions = errors.New("invalid community description no chat permissions")
View Source
var ErrInvalidCommunityDescriptionNoOrgPermissions = errors.New("invalid community description no org permissions")
View Source
var ErrInvalidCommunityDescriptionUnknownChatAccess = errors.New("invalid community description unknown chat access")
View Source
var ErrInvalidCommunityDescriptionUnknownOrgAccess = errors.New("invalid community description unknown org access")
View Source
var ErrInvalidGrant = errors.New("invalid grant")
View Source
var ErrInvalidMessage = errors.New("invalid community description message")
View Source
var ErrNotAdmin = errors.New("no admin privileges for this community")
View Source
var ErrNotAuthorized = errors.New("not authorized")
View Source
var ErrOrgNotFound = errors.New("community not found")
Functions ¶
func ValidateCommunityDescription ¶
func ValidateCommunityDescription(desc *protobuf.CommunityDescription) error
Types ¶
type Community ¶
type Community struct {
// contains filtered or unexported fields
}
func (*Community) BanUserFromCommunity ¶ added in v0.73.9
func (*Community) CanManageUsers ¶ added in v0.72.0
func (*Community) CanManageUsersPublicKeys ¶ added in v0.74.2
func (*Community) CanRequestAccess ¶ added in v0.72.0
func (*Community) CreateChat ¶
func (o *Community) CreateChat(chatID string, chat *protobuf.CommunityChat) (*CommunityChanges, error)
func (*Community) DeleteChat ¶
func (o *Community) DeleteChat(chatID string) (*protobuf.CommunityDescription, error)
func (*Community) Description ¶ added in v0.76.3
func (*Community) Edit ¶ added in v0.79.0
func (o *Community) Edit(description *protobuf.CommunityDescription)
func (*Community) InvitationOnly ¶ added in v0.72.0
func (*Community) InviteUserToChat ¶
func (*Community) InviteUserToOrg ¶
func (*Community) IsMemberAdmin ¶ added in v0.74.2
func (*Community) IsMemberInChat ¶
func (*Community) MarshalJSON ¶
func (*Community) MarshaledDescription ¶
func (*Community) MembersCount ¶ added in v0.76.3
func (*Community) PrivateKey ¶
func (o *Community) PrivateKey() *ecdsa.PrivateKey
func (*Community) RemoveUserFromChat ¶
func (*Community) RemoveUserFromOrg ¶
func (*Community) RequestedToJoinAt ¶ added in v0.72.0
func (*Community) UpdateCommunityDescription ¶ added in v0.72.0
func (o *Community) UpdateCommunityDescription(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, rawMessage []byte) (*CommunityChanges, error)
UpdateCommunityDescription will update the community to the new community description and return a list of changes
func (*Community) ValidateRequestToJoin ¶ added in v0.72.0
func (o *Community) ValidateRequestToJoin(signer *ecdsa.PublicKey, request *protobuf.CommunityRequestToJoin) error
ValidateRequestToJoin validates a request, checks that the right permissions are applied
type CommunityChanges ¶
type CommunityChanges struct { Community *Community `json:"community"` MembersAdded map[string]*protobuf.CommunityMember `json:"membersAdded"` MembersRemoved map[string]*protobuf.CommunityMember `json:"membersRemoved"` ChatsRemoved map[string]*protobuf.CommunityChat `json:"chatsRemoved"` ChatsAdded map[string]*protobuf.CommunityChat `json:"chatsAdded"` ChatsModified map[string]*CommunityChatChanges `json:"chatsModified"` // ShouldMemberJoin indicates whether the user should join this community // automatically ShouldMemberJoin bool `json:"memberAdded"` // ShouldMemberJoin indicates whether the user should leave this community // automatically ShouldMemberLeave bool `json:"memberRemoved"` }
func (*CommunityChanges) HasMemberLeft ¶ added in v0.72.0
func (c *CommunityChanges) HasMemberLeft(identity string) bool
func (*CommunityChanges) HasNewMember ¶ added in v0.72.0
func (c *CommunityChanges) HasNewMember(identity string) bool
type CommunityChat ¶ added in v0.72.0
type CommunityChat struct { ID string `json:"id"` Name string `json:"name"` Members map[string]*protobuf.CommunityMember `json:"members"` Permissions *protobuf.CommunityPermissions `json:"permissions"` CanPost bool `json:"canPost"` }
type CommunityChatChanges ¶
type CommunityChatChanges struct { MembersAdded map[string]*protobuf.CommunityMember MembersRemoved map[string]*protobuf.CommunityMember }
type CommunityResponse ¶ added in v0.72.0
type CommunityResponse struct { Community *Community `json:"community"` Changes *CommunityChanges `json:"changes"` }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) AcceptRequestToJoin ¶ added in v0.72.0
func (m *Manager) AcceptRequestToJoin(request *requests.AcceptRequestToJoinCommunity) (*Community, error)
func (*Manager) BanUserFromCommunity ¶ added in v0.73.9
func (m *Manager) BanUserFromCommunity(request *requests.BanUserFromCommunity) (*Community, error)
func (*Manager) CreateChat ¶
func (m *Manager) CreateChat(communityID types.HexBytes, chat *protobuf.CommunityChat) (*Community, *CommunityChanges, error)
func (*Manager) CreateCommunity ¶
func (m *Manager) CreateCommunity(request *requests.CreateCommunity) (*Community, error)
CreateCommunity takes a description, generates an ID for it, saves it and return it
func (*Manager) DeclineRequestToJoin ¶ added in v0.72.0
func (m *Manager) DeclineRequestToJoin(request *requests.DeclineRequestToJoinCommunity) error
func (*Manager) EditCommunity ¶ added in v0.79.0
func (m *Manager) EditCommunity(request *requests.EditCommunity) (*Community, error)
CreateCommunity takes a description, updates the community with the description, saves it and returns it
func (*Manager) ExportCommunity ¶
func (*Manager) GetByIDString ¶
func (*Manager) HandleCommunityDescriptionMessage ¶
func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, payload []byte) (*CommunityResponse, error)
func (*Manager) HandleCommunityInvitation ¶
func (m *Manager) HandleCommunityInvitation(signer *ecdsa.PublicKey, invitation *protobuf.CommunityInvitation, payload []byte) (*CommunityResponse, error)
TODO: This is not fully implemented, we want to save the grant passed at this stage and make sure it's used when publishing.
func (*Manager) HandleCommunityRequestToJoin ¶ added in v0.72.0
func (m *Manager) HandleCommunityRequestToJoin(signer *ecdsa.PublicKey, request *protobuf.CommunityRequestToJoin) (*RequestToJoin, error)
func (*Manager) HandleWrappedCommunityDescriptionMessage ¶
func (m *Manager) HandleWrappedCommunityDescriptionMessage(payload []byte) (*CommunityResponse, error)
func (*Manager) ImportCommunity ¶
func (m *Manager) ImportCommunity(key *ecdsa.PrivateKey) (*Community, error)
func (*Manager) InviteUsersToCommunity ¶ added in v0.72.0
func (*Manager) JoinCommunity ¶
func (*Manager) LeaveCommunity ¶
func (*Manager) PendingRequestsToJoinForCommunity ¶ added in v0.72.0
func (m *Manager) PendingRequestsToJoinForCommunity(id types.HexBytes) ([]*RequestToJoin, error)
func (*Manager) PendingRequestsToJoinForUser ¶ added in v0.72.0
func (m *Manager) PendingRequestsToJoinForUser(pk *ecdsa.PublicKey) ([]*RequestToJoin, error)
func (*Manager) RemoveUserFromCommunity ¶
func (*Manager) RequestToJoin ¶ added in v0.72.0
func (m *Manager) RequestToJoin(requester *ecdsa.PublicKey, request *requests.RequestToJoinCommunity) (*Community, *RequestToJoin, error)
func (*Manager) Subscribe ¶
func (m *Manager) Subscribe() chan *Subscription
type Persistence ¶
type Persistence struct {
// contains filtered or unexported fields
}
func (*Persistence) AllCommunities ¶
func (p *Persistence) AllCommunities(memberIdentity *ecdsa.PublicKey) ([]*Community, error)
func (*Persistence) CreatedCommunities ¶
func (p *Persistence) CreatedCommunities(memberIdentity *ecdsa.PublicKey) ([]*Community, error)
func (*Persistence) GetRequestToJoin ¶ added in v0.72.0
func (p *Persistence) GetRequestToJoin(id []byte) (*RequestToJoin, error)
func (*Persistence) HasPendingRequestsToJoinForUserAndCommunity ¶ added in v0.72.0
func (p *Persistence) HasPendingRequestsToJoinForUserAndCommunity(userPk string, communityID []byte) (bool, error)
func (*Persistence) JoinedCommunities ¶
func (p *Persistence) JoinedCommunities(memberIdentity *ecdsa.PublicKey) ([]*Community, error)
func (*Persistence) PendingRequestsToJoinForCommunity ¶ added in v0.72.0
func (p *Persistence) PendingRequestsToJoinForCommunity(id []byte) ([]*RequestToJoin, error)
func (*Persistence) PendingRequestsToJoinForUser ¶ added in v0.72.0
func (p *Persistence) PendingRequestsToJoinForUser(pk string) ([]*RequestToJoin, error)
func (*Persistence) SaveCommunity ¶
func (p *Persistence) SaveCommunity(community *Community) error
func (*Persistence) SaveRequestToJoin ¶ added in v0.72.0
func (p *Persistence) SaveRequestToJoin(request *RequestToJoin) (err error)
func (*Persistence) SetRequestToJoinState ¶ added in v0.72.0
func (p *Persistence) SetRequestToJoinState(pk string, communityID []byte, state uint) error
type RequestToJoin ¶ added in v0.72.0
type RequestToJoin struct { ID types.HexBytes `json:"id"` PublicKey string `json:"publicKey"` Clock uint64 `json:"clock"` ENSName string `json:"ensName,omitempty"` ChatID string `json:"chatId"` CommunityID types.HexBytes `json:"communityId"` State uint `json:"state"` Our bool `json:"our"` }
func (*RequestToJoin) CalculateID ¶ added in v0.72.0
func (r *RequestToJoin) CalculateID()
type Subscription ¶
type Subscription struct { Community *Community Invitations []*protobuf.CommunityInvitation }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.