chat

package
v0.179.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChatNotFound            = errors.New("can't find chat")
	ErrCommunityNotFound       = errors.New("can't find community")
	ErrCommunitiesNotSupported = errors.New("communities are not supported")
	ErrChatTypeNotSupported    = errors.New("chat type not supported")
)

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(service *Service) *API

func (*API) AddMembers

func (api *API) AddMembers(ctx context.Context, communityID types.HexBytes, chatID string, members []string) (*GroupChatResponseWithInvitations, error)

func (*API) CreateGroupChat

func (api *API) CreateGroupChat(ctx context.Context, communityID types.HexBytes, name string, members []string) (*GroupChatResponse, error)

func (*API) CreateGroupChatFromInvitation

func (api *API) CreateGroupChatFromInvitation(communityID types.HexBytes, name string, chatID string, adminPK string) (*GroupChatResponse, error)

func (*API) CreateOneToOneChat

func (api *API) CreateOneToOneChat(ctx context.Context, communityID types.HexBytes, ID types.HexBytes, ensName string) (*CreateOneToOneChatResponse, error)

func (*API) EditChat added in v0.105.1

func (api *API) EditChat(ctx context.Context, communityID types.HexBytes, chatID string, name string, color string, image images.CroppedImage) (*Chat, error)

func (*API) GetChannelGroupByID added in v0.148.4

func (api *API) GetChannelGroupByID(ctx context.Context, channelGroupID string) (map[string]ChannelGroup, error)

func (*API) GetChannelGroups added in v0.140.2

func (api *API) GetChannelGroups(ctx context.Context) (map[string]ChannelGroup, error)

func (*API) GetChat

func (api *API) GetChat(ctx context.Context, communityID types.HexBytes, chatID string) (*Chat, error)

func (*API) GetGroupChatInvitations

func (api *API) GetGroupChatInvitations() ([]*protocol.GroupChatInvitation, error)

func (*API) GetMembers

func (api *API) GetMembers(ctx context.Context, communityID types.HexBytes, chatID string) (map[string]Member, error)

func (*API) JoinChat

func (api *API) JoinChat(ctx context.Context, communityID types.HexBytes, chatID string) (*Chat, error)

func (*API) LeaveChat

func (api *API) LeaveChat(ctx context.Context, communityID types.HexBytes, chatID string, remove bool) (*GroupChatResponse, error)

func (*API) MakeAdmin

func (api *API) MakeAdmin(ctx context.Context, communityID types.HexBytes, chatID string, member string) (*GroupChatResponse, error)

func (*API) RemoveMember

func (api *API) RemoveMember(ctx context.Context, communityID types.HexBytes, chatID string, member string) (*GroupChatResponse, error)

func (*API) RenameChat

func (api *API) RenameChat(ctx context.Context, communityID types.HexBytes, chatID string, name string) (*GroupChatResponse, error)

func (*API) SendAudio

func (api *API) SendAudio(ctx context.Context, communityID types.HexBytes, chatID string, audioPath string, responseTo string) (*SendMessageResponse, error)

func (*API) SendGroupChatInvitationRejection

func (api *API) SendGroupChatInvitationRejection(ctx context.Context, invitationRequestID string) ([]*protocol.GroupChatInvitation, error)

func (*API) SendGroupChatInvitationRequest

func (api *API) SendGroupChatInvitationRequest(ctx context.Context, communityID types.HexBytes, chatID string, adminPK string, message string) (*GroupChatResponseWithInvitations, error)

func (*API) SendImages

func (api *API) SendImages(ctx context.Context, communityID types.HexBytes, chatID string, imagePaths []string, text string, responseTo string) (*SendMessageResponse, error)

func (*API) SendMessage

func (api *API) SendMessage(ctx context.Context, communityID types.HexBytes, chatID string, text string, responseTo string) (*SendMessageResponse, error)

func (*API) SendSticker

func (api *API) SendSticker(ctx context.Context, communityID types.HexBytes, chatID string, packID int32, hash string, responseTo string) (*SendMessageResponse, error)

func (*API) StartGroupChat

func (api *API) StartGroupChat(ctx context.Context, communityID types.HexBytes, name string, members []string) (*StartGroupChatResponse, error)

type ChannelGroup

type ChannelGroup struct {
	Type                            ChannelGroupType                                        `json:"channelGroupType"`
	Name                            string                                                  `json:"name"`
	Images                          map[string]images.IdentityImage                         `json:"images"`
	Color                           string                                                  `json:"color"`
	Chats                           map[string]*Chat                                        `json:"chats"`
	Categories                      map[string]communities.CommunityCategory                `json:"categories"`
	EnsName                         string                                                  `json:"ensName"`
	MemberRole                      protobuf.CommunityMember_Roles                          `json:"memberRole"`
	Verified                        bool                                                    `json:"verified"`
	Description                     string                                                  `json:"description"`
	IntroMessage                    string                                                  `json:"introMessage"`
	OutroMessage                    string                                                  `json:"outroMessage"`
	Tags                            []communities.CommunityTag                              `json:"tags"`
	Permissions                     *protobuf.CommunityPermissions                          `json:"permissions"`
	Members                         map[string]*protobuf.CommunityMember                    `json:"members"`
	CanManageUsers                  bool                                                    `json:"canManageUsers"`
	Muted                           bool                                                    `json:"muted"`
	BanList                         []string                                                `json:"banList"`
	Encrypted                       bool                                                    `json:"encrypted"`
	CommunityTokensMetadata         []*protobuf.CommunityTokenMetadata                      `json:"communityTokensMetadata"`
	UnviewedMessagesCount           int                                                     `json:"unviewedMessagesCount"`
	UnviewedMentionsCount           int                                                     `json:"unviewedMentionsCount"`
	CheckChannelPermissionResponses map[string]*communities.CheckChannelPermissionsResponse `json:"checkChannelPermissionResponses"`
	PubsubTopic                     string                                                  `json:"pubsubTopic"`
	PubsubTopicKey                  string                                                  `json:"pubsubTopicKey"`
	Shard                           *shard.Shard                                            `json:"shard"`
}

type ChannelGroupType

type ChannelGroupType string
const Community ChannelGroupType = "community"
const Personal ChannelGroupType = "personal"

type Chat

type Chat struct {
	ID                       string                             `json:"id"`
	Name                     string                             `json:"name"`
	Description              string                             `json:"description"`
	Color                    string                             `json:"color"`
	Emoji                    string                             `json:"emoji"`
	Active                   bool                               `json:"active"`
	ChatType                 protocol.ChatType                  `json:"chatType"`
	Timestamp                int64                              `json:"timestamp"`
	LastClockValue           uint64                             `json:"lastClockValue"`
	DeletedAtClockValue      uint64                             `json:"deletedAtClockValue"`
	ReadMessagesAtClockValue uint64                             `json:"readMessagesAtClockValue"`
	UnviewedMessagesCount    uint                               `json:"unviewedMessagesCount"`
	UnviewedMentionsCount    uint                               `json:"unviewedMentionsCount"`
	LastMessage              *common.Message                    `json:"lastMessage"`
	Members                  map[string]Member                  `json:"members,omitempty"`
	MembershipUpdates        []v1protocol.MembershipUpdateEvent `json:"membershipUpdateEvents"`
	Alias                    string                             `json:"alias,omitempty"`
	Identicon                string                             `json:"identicon"`
	Muted                    bool                               `json:"muted"`
	InvitationAdmin          string                             `json:"invitationAdmin,omitempty"`
	ReceivedInvitationAdmin  string                             `json:"receivedInvitationAdmin,omitempty"`
	Profile                  string                             `json:"profile,omitempty"`
	CommunityID              string                             `json:"communityId"`
	CategoryID               string                             `json:"categoryId"`
	Position                 int32                              `json:"position,omitempty"`
	Permissions              *protobuf.CommunityPermissions     `json:"permissions,omitempty"`
	Joined                   int64                              `json:"joined,omitempty"`
	SyncedTo                 uint32                             `json:"syncedTo,omitempty"`
	SyncedFrom               uint32                             `json:"syncedFrom,omitempty"`
	FirstMessageTimestamp    uint32                             `json:"firstMessageTimestamp,omitempty"`
	Highlight                bool                               `json:"highlight,omitempty"`
	PinnedMessages           *PinnedMessages                    `json:"pinnedMessages,omitempty"`
	// Deprecated: CanPost is deprecated in favor of CanPostMessages/CanPostReactions/etc.
	// For now CanPost will equal to CanPostMessages.
	CanPost                 bool   `json:"canPost"`
	CanPostMessages         bool   `json:"canPostMessages"`
	CanPostReactions        bool   `json:"canPostReactions"`
	ViewersCanPostReactions bool   `json:"viewersCanPostReactions"`
	Base64Image             string `json:"image,omitempty"`
	HideIfPermissionsNotMet bool   `json:"hideIfPermissionsNotMet,omitempty"`
}

type CreateOneToOneChatResponse

type CreateOneToOneChatResponse struct {
	Chat    *Chat             `json:"chat,omitempty"`
	Contact *protocol.Contact `json:"contact,omitempty"`
}

type GroupChatResponse

type GroupChatResponse struct {
	Chat     *Chat             `json:"chat"`
	Messages []*common.Message `json:"messages"`
}

type GroupChatResponseWithInvitations

type GroupChatResponseWithInvitations struct {
	Chat        *Chat                           `json:"chat"`
	Messages    []*common.Message               `json:"messages"`
	Invitations []*protocol.GroupChatInvitation `json:"invitations"`
}

type Member

type Member struct {
	// Community Role
	Role protobuf.CommunityMember_Roles `json:"role,omitempty"`
	// Joined indicates if the member has joined the group chat
	Joined bool `json:"joined"`
}

type PinnedMessages

type PinnedMessages struct {
	Cursor         string
	PinnedMessages []*common.PinnedMessage
}

type SendMessageResponse

type SendMessageResponse struct {
	Chat     *Chat             `json:"chat"`
	Messages []*common.Message `json:"messages"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(accountsDB *accounts.Database) *Service

func (*Service) APIs

func (s *Service) APIs() []gethrpc.API

func (*Service) Init

func (s *Service) Init(messenger *protocol.Messenger)

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

type StartGroupChatResponse

type StartGroupChatResponse struct {
	Chat     *Chat               `json:"chat,omitempty"`
	Contacts []*protocol.Contact `json:"contacts"`
	Messages []*common.Message   `json:"messages,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL