chat

package
v0.110.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChatNotFound            = errors.New("can't find chat")
	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) GetChat

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

func (*API) GetChats

func (api *API) GetChats(ctx context.Context) (map[string]ChannelGroup, 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) (*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"`
	Admin          bool                                     `json:"admin"`
	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"`
}

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"`
	CanPost                  bool                               `json:"canPost"`
	Base64Image              string                             `json:"image,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 Roles
	Roles []protobuf.CommunityMember_Roles `json:"roles,omitempty"`
	// Admin indicates if the member is an admin of the group chat
	Admin bool `json:"admin"`
	// 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