services

package
v0.0.0-...-05e4c81 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	GetProfile(accessToken string) (*models.User, *conf.ApiError)

	GetUser(profileID string) (*models.User, *conf.ApiError)
}

type BroadcastPackage

type BroadcastPackage struct {
	Message  *models.Message
	Auditory []string
}

type Chat

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

func NewChat

func NewChat(
	chatConf conf.ChatConf,
	chatDB db.Chat,
	chatLogDB db.ChatLog,
	memberInfoDB db.MemberInfo,
	roomCache db.RoomCache,
	connectionManager *ConnectionManager,
) *Chat

func (*Chat) AddMessage

func (c *Chat) AddMessage(message models.Message) (*models.Message, *conf.ApiError)

Adds new message to the chat log Additionally checks that current user is a member of that chat room.

func (*Chat) AddReaction

func (c *Chat) AddReaction(profileID string, roomID string, messageID string, reaction string) *conf.ApiError

Adds reaction to a specific message

func (*Chat) AddRoomMember

func (c *Chat) AddRoomMember(profileID string, roomID string, memberID string) (*models.Room, *conf.ApiError)

Add room member to a specific chat room. Checks if members count exceeds the configured maximum

func (*Chat) CreateRoom

func (c *Chat) CreateRoom(profileID string, room models.Room) (*models.Room, *conf.ApiError)

Checks if user exceeds the maximum of opened chat rooms and creates a new room

func (*Chat) DeleteRoom

func (c *Chat) DeleteRoom(profileID string, roomID string) *conf.ApiError

Remove room association of the current user. If user is an owner of the specific group chat then this chat will be deleted.

func (*Chat) EditMessage

func (c *Chat) EditMessage(profileID string, messageID string, body string) *conf.ApiError

Modifies the specific message

func (*Chat) GetAllMembersInfo

func (c *Chat) GetAllMembersInfo(profileID string, roomID string) ([]models.MemberInfo, *conf.ApiError)

Returns all chat members info

func (*Chat) GetAllRoomsInfo

func (c *Chat) GetAllRoomsInfo(profileID string) ([]models.MemberInfo, *conf.ApiError)

Returns all chat member infos for a given member

func (*Chat) GetMemberInfo

func (c *Chat) GetMemberInfo(profileID string, roomID string) (*models.MemberInfo, *conf.ApiError)

Returns chat member info

func (*Chat) GetMessages

func (c *Chat) GetMessages(profileID string, roomID string, from time.Time, limit int) ([]models.Message, *conf.ApiError)

Returns chat log for a given period

func (*Chat) GetRoom

func (c *Chat) GetRoom(profileID string, roomID string) (*models.Room, *conf.ApiError)

Returns a specific room by id where current user is member of

func (*Chat) GetRooms

func (c *Chat) GetRooms(profileID string) ([]models.Room, *conf.ApiError)

Returns list of rooms that current user is member of

func (*Chat) RemoveRoomMember

func (c *Chat) RemoveRoomMember(profileID string, roomID string, memberID string) *conf.ApiError

Removes room member by the room owner. If there are no more members then delete the room entirely.

func (*Chat) UpdateLastReadTime

func (c *Chat) UpdateLastReadTime(profileID string, roomID string) *conf.ApiError

Updates last read time for a given chat member

type Connection

type Connection struct {
	UserID   string              // abstract user ID
	DeviceID middleware.DeviceID // user device ID to support chats opened on several devices
	Socket   *websocket.Conn     // socket connection for incoming messages and notifications
}

Connection DTO for channel

type ConnectionManager

type ConnectionManager struct {
	Connections map[string]map[middleware.DeviceID]*websocket.Conn
	Register    chan *Connection
	Unregister  chan *Connection
	Broadcast   chan *BroadcastPackage
	// contains filtered or unexported fields
}

func NewConnectionManager

func NewConnectionManager(bus db.Bus, socketConf conf.SocketConf) *ConnectionManager

type FBError

type FBError struct {
	Error conf.ApiError `json:"error"`
}

Error in the format returned by the facebook.com

type FBPermission

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

type FBPermissionsResponse

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

type Facebook

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

Facebook Service performs necessary operations related to the Facebook.com social network such as:

  • retrieving client token by service credentials
  • exchanging authorization code to access token
  • retrieving user profile
  • retrieving user friends list
  • retrieving user by id

func NewFacebook

func NewFacebook(options conf.FacebookConf, httpClient *http.Client) (f *Facebook)

func (*Facebook) ExchangeCodeToToken

func (f *Facebook) ExchangeCodeToToken(accessCode string) (string, *conf.ApiError)

Exchanges user authorization code to its access token.

func (*Facebook) GetFriends

func (f *Facebook) GetFriends(profileID string) ([]models.User, *conf.ApiError)

Retrieves user friends list.

func (*Facebook) GetProfile

func (f *Facebook) GetProfile(accessToken string) (*models.User, *conf.ApiError)

Retrieves user profile using access token.

func (*Facebook) GetUser

func (f *Facebook) GetUser(profileID string) (*models.User, *conf.ApiError)

Retrieves user by its ID.

func (*Facebook) HasFriendsPermissions

func (f *Facebook) HasFriendsPermissions(profileID string) *conf.ApiError

type Friends

type Friends interface {
	GetFriends(profileID string) ([]models.User, *conf.ApiError)

	HasFriendsPermissions(profileID string) *conf.ApiError
}

type MessageJob

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

type OAuth

type OAuth interface {
	ExchangeCodeToToken(accessCode string) (string, *conf.ApiError)
}

Jump to

Keyboard shortcuts

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