models

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: MIT Imports: 5 Imported by: 10

Documentation

Index

Constants

View Source
const (
	PLATFORM_IOS = iota + 1
	PLATFORM_ANDROID
)
View Source
const (
	MESSAGE_TYPE_TEXT  = "text"
	MESSAGE_TYPE_IMAGE = "image"
)
View Source
const (
	ERROR_NAME_INVALID_JSON            = "invalid-json"
	ERROR_NAME_INVALID_PARAM           = "invalid-param"
	ERROR_NAME_DATABASE_ERROR          = "database-error"
	ERROR_NAME_NOTIFICATION_ERROR      = "notification-error"
	ERROR_NAME_OPERATION_NOT_PERMITTED = "operation-not-permitted"
)

Variables

This section is empty.

Functions

func IsValidDevicePlatform added in v0.2.0

func IsValidDevicePlatform(platform int) bool

Types

type Api added in v0.6.0

type Api struct {
	Id      uint64 `json:"-" db:"id"`
	Name    string `json:"name" db:"name,notnull"`
	Key     string `json:"key" db:"key,notnull"`
	Secret  string `json:"secret" db:"secret,notnull"`
	Created int64  `json:"created" db:"created,notnull"`
	Expired int64  `json:"expired" db:"expired,notnull"`
}

func (*Api) MarshalJSON added in v0.6.0

func (a *Api) MarshalJSON() ([]byte, error)

type Asset

type Asset struct {
	AssetId   string `json:"assetId"`
	SourceUrl string `json:"sourceUrl"`
	Mime      string `json:"mime"`
}

type BlockUser added in v0.7.0

type BlockUser struct {
	UserId      string `json:"userId" db:"user_id,notnull"`
	BlockUserId string `json:"blockUserId" db:"block_user_id,notnull"`
	Created     int64  `json:"created" db:"created,notnull"`
}

func (*BlockUser) MarshalJSON added in v0.7.0

func (bu *BlockUser) MarshalJSON() ([]byte, error)

type BlockUsers added in v0.7.0

type BlockUsers struct {
	BlockUsers []string `json:"blockUsers"`
}

type Device added in v0.2.0

type Device struct {
	UserId               string `json:"userId,omitempty" db:"user_id,notnull"`
	Platform             int    `json:"platform,omitempty" db:"platform,notnull"`
	Token                string `json:"token,omitempty" db:"token,notnull"`
	NotificationDeviceId string `json:"notificationDeviceId,omitempty" db:"notification_device_id"`
}

func (*Device) IsValid added in v0.2.0

func (d *Device) IsValid() *ProblemDetail

type Devices added in v0.2.0

type Devices struct {
	Devices []*Device `json:"devices"`
}

type ErrorRoomUser

type ErrorRoomUser struct {
	UserId string         `json:"userId,omitempty"`
	Error  *ProblemDetail `json:"error"`
}

type InvalidParam

type InvalidParam struct {
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

type Message

type Message struct {
	Id        uint64         `json:"-" db:"id"`
	MessageId string         `json:"messageId" db:"message_id,notnull"`
	RoomId    string         `json:"roomId" db:"room_id,notnull"`
	UserId    string         `json:"userId" db:"user_id,notnull"`
	Type      string         `json:"type,omitempty" db:"type"`
	EventName string         `json:"eventName,omitempty" db:"-"`
	Payload   utils.JSONText `json:"payload" db:"payload"`
	Created   int64          `json:"created" db:"created,notnull"`
	Modified  int64          `json:"modified" db:"modified,notnull"`
	Deleted   int64          `json:"-" db:"deleted,notnull"`
}

func (*Message) BeforeSave added in v0.2.0

func (m *Message) BeforeSave()

func (*Message) IsValid added in v0.2.0

func (m *Message) IsValid() *ProblemDetail

func (*Message) MarshalJSON added in v0.4.0

func (m *Message) MarshalJSON() ([]byte, error)

type Messages

type Messages struct {
	Messages []*Message `json:"messages" db:"-"`
	AllCount int64      `json:"allCount" db:"all_count"`
}

type PayloadImage

type PayloadImage struct {
	Mime         string `json:"mime"`
	SourceUrl    string `json:"sourceUrl"`
	ThumbnailUrl string `json:"thumbnailUrl"`
}

type PayloadLocation

type PayloadLocation struct {
	Title     string  `json:"title"`
	Address   string  `json:"address"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type PayloadText

type PayloadText struct {
	Text string `json:"text"`
}

type PayloadUsers

type PayloadUsers struct {
	Users []string `json:"users"`
}

type ProblemDetail

type ProblemDetail struct {
	Type          string         `json:"type,omitempty"`
	Title         string         `json:"title"`
	Status        int            `json:"status,omitempty"`
	Detail        string         `json:"detail,omitempty"`
	Instance      string         `json:"instance,omitempty"`
	ErrorName     string         `json:"errorName"`
	InvalidParams []InvalidParam `json:"invalidParams,omitempty"`
	Error         error          `json:"-"`
}

type RequestBlockUserIds added in v0.7.0

type RequestBlockUserIds struct {
	UserIds []string `json:"userIds,omitempty"`
}

func (*RequestBlockUserIds) IsValid added in v0.7.0

func (reqUIDs *RequestBlockUserIds) IsValid(userId string) *ProblemDetail

func (*RequestBlockUserIds) RemoveDuplicate added in v0.7.0

func (reqUIDs *RequestBlockUserIds) RemoveDuplicate()

type RequestRoomUserIds added in v0.2.0

type RequestRoomUserIds struct {
	UserIds []string `json:"userIds,omitempty" db:"-"`
}

func (*RequestRoomUserIds) IsValid added in v0.2.0

func (rus *RequestRoomUserIds) IsValid(method string, r *Room) *ProblemDetail

func (*RequestRoomUserIds) RemoveDuplicate added in v0.2.0

func (rus *RequestRoomUserIds) RemoveDuplicate()

type ResponseMessages

type ResponseMessages struct {
	MessageIds []string         `json:"messageIds,omitempty"`
	Errors     []*ProblemDetail `json:"errors,omitempty"`
}

type ResponseRoomUser

type ResponseRoomUser struct {
	RoomUsers []RoomUser      `json:"roomUsers,omitempty"`
	Errors    []ErrorRoomUser `json:"errors,omitempty"`
}

type Room

type Room struct {
	Id                    uint64         `json:"-" db:"id"`
	RoomId                string         `json:"roomId" db:"room_id,notnull"`
	UserId                string         `json:"userId" db:"user_id,notnull"`
	Name                  string         `json:"name" db:"name,notnull"`
	PictureUrl            string         `json:"pictureUrl,omitempty" db:"picture_url"`
	InformationUrl        string         `json:"informationUrl,omitempty" db:"information_url"`
	MetaData              utils.JSONText `json:"metaData" db:"meta_data"`
	AvailableMessageTypes string         `json:"availableMessageTypes,omitempty" db:"available_message_types"`
	Type                  *RoomType      `json:"type,omitempty" db:"type,notnull"`
	LastMessage           string         `json:"lastMessage" db:"last_message"`
	LastMessageUpdated    int64          `json:"lastMessageUpdated" db:"last_message_updated,notnull"`
	MessageCount          int64          `json:"messageCount" db:"-"`
	NotificationTopicId   string         `json:"notificationTopicId,omitempty" db:"notification_topic_id"`
	IsCanLeft             *bool          `json:"isCanLeft,omitempty" db:"is_can_left,notnull"`
	IsShowUsers           *bool          `json:"isShowUsers,omitempty" db:"is_show_users,notnull"`
	Created               int64          `json:"created" db:"created,notnull"`
	Modified              int64          `json:"modified" db:"modified,notnull"`
	Deleted               int64          `json:"-" db:"deleted,notnull"`

	Users []*UserForRoom `json:"users,omitempty" db:"-"`
	RequestRoomUserIds
}

func (*Room) BeforeSave added in v0.2.0

func (r *Room) BeforeSave()

func (*Room) IsValid added in v0.2.0

func (r *Room) IsValid() *ProblemDetail

func (*Room) MarshalJSON added in v0.4.0

func (r *Room) MarshalJSON() ([]byte, error)

func (*Room) Put added in v0.2.0

func (r *Room) Put(put *Room) *ProblemDetail

type RoomForUser

type RoomForUser struct {
	// from room
	RoomId             string         `json:"roomId" db:"room_id"`
	UserId             string         `json:"userId" db:"user_id"`
	Name               string         `json:"name" db:"name"`
	PictureUrl         string         `json:"pictureUrl,omitempty" db:"picture_url"`
	InformationUrl     string         `json:"informationUrl,omitempty" db:"information_url"`
	MetaData           utils.JSONText `json:"metaData" db:"meta_data"`
	Type               *RoomType      `json:"type,omitempty" db:"type"`
	LastMessage        string         `json:"lastMessage" db:"last_message"`
	LastMessageUpdated int64          `json:"lastMessageUpdated" db:"last_message_updated"`
	IsCanLeft          *bool          `json:"isCanLeft,omitempty" db:"is_can_left,notnull"`
	Created            int64          `json:"created" db:"created"`
	Modified           int64          `json:"modified" db:"modified"`

	Users []*UserMini `json:"users" db:"-"`

	// from RoomUser
	RuUnreadCount int64          `json:"ruUnreadCount" db:"ru_unread_count"`
	RuMetaData    utils.JSONText `json:"ruMetaData" db:"ru_meta_data"`
	RuCreated     int64          `json:"ruCreated" db:"ru_created"`
	RuModified    int64          `json:"ruModified" db:"ru_modified"`
}

func (*RoomForUser) MarshalJSON added in v0.4.0

func (rfu *RoomForUser) MarshalJSON() ([]byte, error)

type RoomType added in v0.7.0

type RoomType int
const (
	ONE_ON_ONE RoomType = iota + 1
	PRIVATE_ROOM
	PUBLIC_ROOM
	NOTICE_ROOM
	ROOM_TYPE_END
)

func (RoomType) String added in v0.7.0

func (rt RoomType) String() string

type RoomUser

type RoomUser struct {
	RoomId      string         `json:"roomId" db:"room_id,notnull"`
	UserId      string         `json:"userId" db:"user_id,notnull"`
	UnreadCount *int64         `json:"unreadCount" db:"unread_count"`
	MetaData    utils.JSONText `json:"metaData" db:"meta_data"`
	Created     int64          `json:"created" db:"created,notnull"`
	Modified    int64          `json:"modified" db:"modified,notnull"`
}

func (*RoomUser) BeforeSave added in v0.2.0

func (ru *RoomUser) BeforeSave()

func (*RoomUser) IsValid added in v0.2.0

func (ru *RoomUser) IsValid() *ProblemDetail

func (*RoomUser) MarshalJSON added in v0.4.0

func (ru *RoomUser) MarshalJSON() ([]byte, error)

func (*RoomUser) Put added in v0.2.0

func (ru *RoomUser) Put(put *RoomUser)

type RoomUsers

type RoomUsers struct {
	RoomUsers []*RoomUser `json:"roomUsers"`
}

type Rooms

type Rooms struct {
	Rooms    []*Room `json:"rooms" db:"-"`
	AllCount int64   `json:"allCount" db:"all_count"`
}

type Subscription added in v0.2.0

type Subscription struct {
	RoomId                     string `json:"roomId" db:"room_id,notnull"`
	UserId                     string `json:"userId" db:"user_id,notnull"`
	Platform                   int    `json:"platform" db:"platform,notnull"`
	NotificationSubscriptionId string `json:"notificationSubscriptionId" db:"notification_subscription_id"`
	Deleted                    int64  `json:"-" db:"deleted,notnull"`
}

type User

type User struct {
	Id             uint64         `json:"-" db:"id"`
	UserId         string         `json:"userId" db:"user_id,notnull"`
	Name           string         `json:"name" db:"name,notnull"`
	PictureUrl     string         `json:"pictureUrl,omitempty" db:"picture_url"`
	InformationUrl string         `json:"informationUrl,omitempty" db:"information_url"`
	UnreadCount    *uint64        `json:"unreadCount,omitempty" db:"unread_count,notnull"`
	MetaData       utils.JSONText `json:"metaData,omitempty" db:"meta_data"`
	IsPublic       *bool          `json:"isPublic,omitempty" db:"is_public,notnull"`
	IsCanBlock     *bool          `json:"isCanBlock,omitempty" db:"is_can_block,notnull"`
	IsShowUsers    *bool          `json:"isShowUsers,omitempty" db:"is_show_users,notnull"`
	AccessToken    string         `json:"accessToken,omitempty" db:"access_token"`
	Created        int64          `json:"created,omitempty" db:"created,notnull"`
	Modified       int64          `json:"modified,omitempty" db:"modified,notnull"`
	Deleted        int64          `json:"-" db:"deleted,notnull"`

	Rooms   []*RoomForUser `json:"rooms,omitempty" db:"-"`
	Devices []*Device      `json:"devices,omitempty" db:"-"`
	Blocks  []string       `json:"blocks,omitempty" db:"-"`
}

func (*User) BeforeSave added in v0.2.0

func (u *User) BeforeSave()

func (*User) IsValid added in v0.2.0

func (u *User) IsValid() *ProblemDetail

func (*User) MarshalJSON added in v0.4.0

func (u *User) MarshalJSON() ([]byte, error)

func (*User) Put added in v0.2.0

func (u *User) Put(put *User)

type UserForRoom

type UserForRoom struct {
	// from User
	UserId         string         `json:"userId" db:"user_id"`
	Name           string         `json:"name" db:"name"`
	PictureUrl     string         `json:"pictureUrl,omitempty" db:"picture_url"`
	InformationUrl string         `json:"informationUrl,omitempty" db:"information_url"`
	MetaData       utils.JSONText `json:"metaData" db:"meta_data"`
	IsCanLeft      *bool          `json:"isCanBlock,omitempty" db:"is_can_block,notnull"`
	IsShowUsers    *bool          `json:"isShowUsers,omitempty" db:"is_show_users,notnull"`
	Created        int64          `json:"created" db:"created"`
	Modified       int64          `json:"modified" db:"modified"`

	// from RoomUser
	RuUnreadCount int64          `json:"ruUnreadCount" db:"ru_unread_count"`
	RuMetaData    utils.JSONText `json:"ruMetaData" db:"ru_meta_data"`
	RuCreated     int64          `json:"ruCreated" db:"ru_created"`
	RuModified    int64          `json:"ruModified" db:"ru_modified"`
}

func (*UserForRoom) MarshalJSON added in v0.4.0

func (ufr *UserForRoom) MarshalJSON() ([]byte, error)

type UserMini added in v0.7.0

type UserMini struct {
	RoomId      string `json:"roomId" db:"room_id"`
	UserId      string `json:"userId" db:"user_id"`
	Name        string `json:"name" db:"name"`
	PictureUrl  string `json:"pictureUrl,omitempty" db:"picture_url"`
	IsShowUsers *bool  `json:"isShowUsers,omitempty" db:"is_show_users"`
}

type UserUnreadCount added in v0.7.1

type UserUnreadCount struct {
	UnreadCount *uint64 `json:"unreadCount" db:"unread_count"`
}

type Users

type Users struct {
	Users []*User `json:"users"`
}

Jump to

Keyboard shortcuts

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