messenger

package
v0.0.0-...-ba645fd Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContactExist = types.AppError{ErrorCode: "contact_exist", Message: "the contact already exists"}
)
View Source
var (
	ErrMessageInvalid = types.AppError{ErrorCode: "invalid_message", Message: "the message's is invalid"}
)

Functions

This section is empty.

Types

type Contact

type Contact struct {
	GroupID   string           `json:"group_id" db:"group_id"`
	MemberID  string           `json:"member_id" db:"member_id"`
	MemberID1 string           `json:"-" db:"member_id_1"`
	MemberID2 string           `json:"-" db:"member_id_2"`
	Member    *identity.Member `json:"member"`
	State     ContactState     `json:"state" db:"state"`
	CreatedAt *time.Time       `json:"created_at" db:"created_at"`
	UpdatedAt *time.Time       `json:"updated_at" db:"updated_at"`
}

type ContactRepository

type ContactRepository interface {
	DB() *sqlx.DB
	Contacts(ctx context.Context, opts *FindContactOptions) ([]*Contact, error)
	InsertTx(ctx context.Context, target *Contact, tx *sqlx.Tx) error
	Block(ctx context.Context, target *Contact) error
}

type ContactServicer

type ContactServicer interface {
	Contacts(ctx context.Context, opts *FindContactOptions) ([]*Contact, error)
	BlockContact(ctx context.Context, memberID, friendID string) error
	AddContact(ctx context.Context, memberID, friendID string) error
}

type ContactState

type ContactState int
const (
	ContactStateNormal ContactState = 1
	ContactStateBlock  ContactState = 2
)

type Conversation

type Conversation struct {
	ID               string            `json:"id" db:"id"`
	GroupID          string            `json:"group_id" db:"group_id"`
	MemberID         string            `json:"-" db:"member_id"`
	IsMute           bool              `json:"is_mute" db:"is_mute"`
	LastAckMessageID string            `json:"last_ack_message_id" db:"last_ack_message_id"`
	State            ConversationState `json:"state" db:"state"`
	CreatedAt        *time.Time        `json:"created_at" db:"created_at"`
	UpdatedAt        *time.Time        `json:"updated_at" db:"updated_at"`
}

type ConversationRepository

type ConversationRepository interface {
	DB() *sqlx.DB
	Conversations(ctx context.Context, opts *FindConversionOptions) ([]*Conversation, error)
	InsertTx(ctx context.Context, target *Conversation, tx *sqlx.Tx) error
}

type ConversationServicer

type ConversationServicer interface {
	Conversations(ctx context.Context, opts *FindConversionOptions) ([]*Conversation, error)
	CreateConversation(ctx context.Context, conversation *Conversation) error
	UnreadMessageCount(ctx context.Context, conversationID string) (int, error)
	MarkAllMessageAsRead(ctx context.Context, conversationID string) error
	GetConversationMessageCount(ctx context.Context, conversationID string) (int, error)
}

type ConversationState

type ConversationState int
const (
	ConversationStateNormal ConversationState = 1
	ConversationStateBlock  ConversationState = 2
	ConversationStateDelete ConversationState = 3
)

type DeliveryServicer

type DeliveryServicer interface {
	DeliveryMessage(ctx context.Context, msg *Message) error
}

type FindContactOptions

type FindContactOptions struct {
	MemberID        string     `db:"member_id"`
	AnchorUpdatedAt *time.Time `db:"anchor_updated_at"`
	Skip            int        `db:"skip"`
	PerPage         int        `db:"per_page"`
}

type FindConversionOptions

type FindConversionOptions struct {
	ID              string
	GroupID         string
	MemberID        string `db:"member_id"`
	SortBy          string
	OrderBy         string
	AnchorUpdatedAt *time.Time `db:"anchor_updated_at"`
	Skip            int        `db:"skip"`
	PerPage         int        `db:"per_page"`
}

type FindGroupMemberOptions

type FindGroupMemberOptions struct {
	GroupID         string     `db:"group_id"`
	AnchorUpdatedAt *time.Time `db:"anchor_updated_at"`
	Skip            int        `db:"skip"`
	PerPage         int        `db:"per_page"`
}

type FindGroupOptions

type FindGroupOptions struct {
	IDs             string `db:"group_ids"`
	Type            GroupType
	MemberID        string     `db:"member_id"`
	AnchorUpdatedAt *time.Time `db:"anchor_updated_at"`
	Skip            int        `db:"skip"`
	PerPage         int        `db:"per_page"`
}

type FindMessagesOptions

type FindMessagesOptions struct {
	ID              string
	MemberID        string
	GroupIDs        []string
	AnchorUpdatedAt *time.Time
	Skip            int
	PerPage         int
}

type Group

type Group struct {
	ID             string     `json:"id" db:"id"`
	Name           string     `json:"name" db:"name"`
	Description    string     `json:"description" db:"description"`
	Type           GroupType  `json:"type" db:"type"`
	MaxMemberCount int        `json:"-" db:"max_member_count"`
	MemberCount    int        `json:"member_count" db:"member_count"`
	CreatorID      string     `json:"-" db:"creator_id"`
	State          GroupState `json:"state" db:"state"`
	CreatedAt      *time.Time `json:"created_at" db:"created_at"`
	UpdatedAt      *time.Time `json:"updated_at" db:"updated_at"`
}

type GroupMember

type GroupMember struct {
	ID        string     `json:"id" db:"id"`
	GroupID   string     `json:"group_id" db:"group_id"`
	MemberID  string     `json:"member_id" db:"member_id"`
	IsAdmin   bool       `json:"is_admin" db:"is_admin"`
	CreatedAt *time.Time `json:"created_at" db:"created_at"`
	UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
}

type GroupMemberRepository

type GroupMemberRepository interface {
	DB() *sqlx.DB
	GroupMembers(ctx context.Context, opts *FindGroupMemberOptions) ([]*GroupMember, error)
	BatchInsertTx(ctx context.Context, members []*GroupMember, tx *sqlx.Tx) error
}

type GroupRepository

type GroupRepository interface {
	DB() *sqlx.DB
	Groups(ctx context.Context, opts *FindGroupOptions) ([]*Group, error)
	InsertTx(ctx context.Context, target *Group, tx *sqlx.Tx) error
	IsMemberInGroup(ctx context.Context, memberID, groupID string) bool
}

type GroupServicer

type GroupServicer interface {
	Groups(ctx context.Context, opts *FindGroupOptions) ([]*Group, error)
	CreateGroup(ctx context.Context, group *Group, memberIDs []string) error
	DissolveGroup(ctx context.Context, groupID string) error // 解散群組
	JoinGroup(ctx context.Context, groupID string, memberID string) error
	LeaveGroup(ctx context.Context, groupID string) error
	AddGroupMember(ctx context.Context, groupID string, memberID string) error
	GroupMembers(ctx context.Context, opts *FindGroupMemberOptions) ([]*GroupMember, error)
	SetAdmin(ctx context.Context, groupID string, memberID string) error
	RemoveAdmin(ctx context.Context, groupID string, memberID string) error
	GroupAdmins(ctx context.Context, groupID string) ([]*GroupMember, error)
}

type GroupState

type GroupState int
const (
	GroupStateNormal    GroupState = 1
	GroupStateDissolved GroupState = 2
)

type GroupType

type GroupType int
const (
	GroupTypeSystem       GroupType = 1
	GroupTypeP2P          GroupType = 2
	GroupTypePrivateGroup GroupType = 3
)

type Message

type Message struct {
	ID              string       `json:"id,omitempty" db:"id"`
	SeqID           int32        `json:"seq_id,omitempty" db:"seq_id"`
	Type            MessageType  `json:"type,omitempty" db:"type"`
	GroupID         string       `json:"group_id,omitempty" db:"group_id"`
	SenderID        string       `json:"sender_id,omitempty" db:"sender_id"`
	SenderFirstName string       `json:"sender_first_name,omitempty" db:"sender_first_name"`
	SenderLastName  string       `json:"sender_last_name,omitempty" db:"sender_last_name"`
	Content         string       `json:"content,omitempty" db:"content"`
	State           MessageState `json:"state,omitempty" db:"state"`
	CreatedAt       *time.Time   `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt       *time.Time   `json:"updated_at,omitempty" db:"updated_at"`
}

type MessageRepository

type MessageRepository interface {
	DB() *sqlx.DB
	BatchInsert(ctx context.Context, targets []*Message) error
}

type MessageServicer

type MessageServicer interface {
	Messages(ctx context.Context, opts *FindMessagesOptions) ([]*Message, error)
	CreateMessage(ctx context.Context, msg *Message) error
	AckMessage(ctx context.Context, conversationID string, ackMsgID string, memberID string) error
}

type MessageState

type MessageState int
const (
	MessageStateNormal MessageState = 1
	MessageStateDelete MessageState = 2
	MessageStateDone   MessageState = 3 // 完成朋友邀請
)

type MessageType

type MessageType int
const (
	MessageTypeNotification MessageType = 1
	MessageTypeText         MessageType = 2
	MessageTypeImage        MessageType = 3
)

Directories

Path Synopsis
delivery
repository

Jump to

Keyboard shortcuts

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