common

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 11 Imported by: 24

Documentation

Index

Constants

View Source
const (
	// GroupMemberSeqKey 群成员序列号key
	GroupMemberSeqKey = "groupMember"
	// GroupSettingSeqKey 群设置序列号key
	GroupSettingSeqKey = "groupSetting"
	// GroupSeqKey 群序列号key
	GroupSeqKey = "group"
	// UserSettingSeqKey 用户设置序列号key
	UserSettingSeqKey = "userSetting"
	// UserSeqKey 用户序列号
	UserSeqKey = "user"
	// FriendSeqKey 好友
	FriendSeqKey = "friend"
	// MessageExtraSeqKey 消息扩展序号
	MessageExtraSeqKey = "messageExtra"
	// MessageReactionSeqKey 消息回应序号
	MessageReactionSeqKey = "messageReaction"
	// RobotSeqKey 机器人序号
	RobotSeqKey = "robot"
	// RobotEventSeqKey 机器人事件序号
	RobotEventSeqKey = "robotEventSeq:"
	// SensitiveWordsKey 敏感词序号
	SensitiveWordsKey = "sensitiveWords"
	// ReminderKey 提醒项序号
	RemindersKey = "reminders"
	// SyncConversationExtraKey 同步最近会话扩展
	SyncConversationExtraKey = "syncConversationExtra"
	// ProhibitWord 违禁词
	ProhibitWordKey = "ProhibitWord"
)
View Source
const (
	// GroupAttrKeyName 群名称
	GroupAttrKeyName = "name"
	// GroupAttrKeyNotice 群公告
	GroupAttrKeyNotice = "notice"
	// GroupAttrKeyForbidden 群禁言
	GroupAttrKeyForbidden = "forbidden"
	// GroupAttrKeyInvite 邀请确认
	GroupAttrKeyInvite = "invite"
	// GroupAttrKeyForbiddenAddFriend 群内禁止加好友
	GroupAttrKeyForbiddenAddFriend = "forbidden_add_friend"
	// GroupAttrKeyStatus 群状态
	GroupAttrKeyStatus = "status"
	// GroupAllowViewHistoryMsg 是否允许新成员查看历史消息
	GroupAllowViewHistoryMsg = "allow_view_history_msg"
)

群属性key

View Source
const (
	// CMDChannelUpdate 频道信息更新
	CMDChannelUpdate = "channelUpdate"
	// CMDGroupMemberUpdate 群成员更新
	CMDGroupMemberUpdate = "memberUpdate"
	// CMDConversationUnreadClear 未读数清空
	CMDConversationUnreadClear = "unreadClear"
	// CMDGroupAvatarUpdate 群头像更新
	CMDGroupAvatarUpdate = "groupAvatarUpdate"
	// CMDCommunityAvatarUpdate 社区头像更新
	CMDCommunityAvatarUpdate = "communityAvatarUpdate"
	// CMDCommunityCoverUpdate 社区封面更新
	CMDCommunityCoverUpdate = "communityCoverUpdate"
	// CMDConversationDelete 删除最近会话
	CMDConversationDelete = "conversationDelete"
	// CMDFriendRequest 好友申请
	CMDFriendRequest = "friendRequest"
	// friendAccept 接受好友申请
	CMDFriendAccept = "friendAccept"
	// friendDeleted 好友被删除
	CMDFriendDeleted = "friendDeleted"
	// userAvatarUpdate 个人头像更新
	CMDUserAvatarUpdate = "userAvatarUpdate"
	// 输入中
	CMDTyping = "typing"
	// 在线状态
	CMDOnlineStatus = "onlineStatus"
	// 动态点赞或评论消息
	CMDMomentMsg = "momentMsg"
	// 同步消息扩展数据
	CMDSyncMessageExtra = "syncMessageExtra"
	// 同步消息回应数据
	CMDSyncMessageReaction = "syncMessageReaction"
	// 退出pc登录
	CMDPCQuit = "pcQuit"
	// 最近会话被删除
	CMDConversationDeleted = "conversationDeleted"
	// 同步提醒项
	CMDSyncReminders = "syncReminders"
	// 同步最近会话扩展
	CMDSyncConversationExtra = "syncConversationExtra"
	// organizationLogoUpdate 组织logo更新
	CMDOrganizationLogoUpdate = "organizationLogoUpdate"
)

命令消息

View Source
const AuthCodeCachePrefix = "authcode:"

AuthCodeCachePrefix 授权code

View Source
const QRCodeCachePrefix = "qrcode:"

QRCodeCachePrefix 二维码缓存前缀

View Source
const UserDeviceBadgePrefix = "userDeviceBadge"

UserDeviceBadgePrefix 用户设备红点

View Source
const UserDeviceTokenPrefix = "userDeviceToken:"

UserDeviceTokenPrefix 用户设备token缓存前缀

Variables

View Source
var ErrData = errors.New("数据格式有误!")

ErrData 数据格式有误

Functions

func GetFakeChannelIDWith

func GetFakeChannelIDWith(fromUID, toUID string) string

GetFakeChannelIDWith GetFakeChannelIDWith

func GetToChannelIDWithFakeChannelID

func GetToChannelIDWithFakeChannelID(fakeChannelID string, uid string) string

获取fakeChannelID里的非uid的uid

func IsFakeChannel

func IsFakeChannel(channelID string) bool

IsFakeChannel 是fake频道

Types

type AuthCodeType

type AuthCodeType string

AuthCodeType 认证代码类型

const AuthCodeTypeGroupMemberInvite AuthCodeType = "groupMemberInvite"

AuthCodeTypeGroupMemberInvite 群成员邀请

const AuthCodeTypeJoinGroup AuthCodeType = "joinGroup"

AuthCodeTypeJoinGroup 进群授权code

const AuthCodeTypeScanLogin AuthCodeType = "scanLogin"

AuthCodeTypeScanLogin 扫描登录

type ChannelType

type ChannelType uint8

ChannelType 频道类型

const (
	// ChannelTypeNone 没有指定频道
	ChannelTypeNone ChannelType = iota
	// ChannelTypePerson 个人频道
	ChannelTypePerson
	// ChannelTypeGroup           群频道
	ChannelTypeGroup
	// ChannelTypeCustomerService 客服频道
	ChannelTypeCustomerService
	// ChannelTypeCommunity 社区
	ChannelTypeCommunity
	// ChannelTypeCommunityTopic 话题
	ChannelTypeCommunityTopic
	//  ChannelTypeInfo 资讯类频道
	ChannelTypeInfo
)

func (ChannelType) Uint8

func (c ChannelType) Uint8() uint8

Uint8 转换为uint8

type ContentType

type ContentType int

ContentType 正文类型

const (

	// Text 文本消息
	Text ContentType = 1 // 文本消息
	// Image 图片消息
	Image ContentType = 2
	// GIF 消息
	GIF ContentType = 3
	//Voice 语音消息
	Voice ContentType = 4
	// Video 视频
	Video ContentType = 5
	// LOCATION 位置
	Location ContentType = 6
	// Card 名片
	Card ContentType = 7
	// File 文件
	File ContentType = 8
	// RedPacket 红包
	RedPacket ContentType = 9
	// Transfer 转账
	Transfer ContentType = 10
	// MultipleForward 合并转发
	MultipleForward = 11
	// VectorSticker 矢量表情
	VectorSticker ContentType = 12
	// EmojiSticker 矢量emoji表情
	EmojiSticker ContentType = 13

	// 消息正文错误
	ContentError ContentType = 97
	// signal 解密失败
	SignalError ContentType = 98
	// CMD 消息
	CMD ContentType = 99

	// ---------- 系统类 ----------
	// Tip 只作为提醒无任何操作类型
	Tip ContentType = 2000
	// FriendApply 好友申请
	FriendApply ContentType = 1000
	// GroupCreate 群创建
	GroupCreate ContentType = 1001
	// GroupMemberAdd 群成员添加
	GroupMemberAdd ContentType = 1002
	// GroupMemberRemove  群成员移除
	GroupMemberRemove ContentType = 1003

	// FriendSure 好友申请
	FriendSure ContentType = 1004
	// GroupUpdate 群更新
	GroupUpdate ContentType = 1005
	// RevokeMessage 撤回消息
	RevokeMessage ContentType = 1006
	// GroupMemberScanJoin 扫码进群
	GroupMemberScanJoin ContentType = 1007
	// GroupTransferGrouper 转让群主
	GroupTransferGrouper ContentType = 1008
	// GroupMemberInvite 群成员邀请
	GroupMemberInvite ContentType = 1009
	// GroupMemberBeRemove  群成员被移除(被踢)
	GroupMemberBeRemove ContentType = 1020
	// GroupMemberBeRemove 群成员主动退出群聊
	GroupMemberQuit ContentType = 1021
	// 群升级
	GroupUpgrade ContentType = 1022

	// RedpacketReceive 红包领取
	RedpacketReceive ContentType = 1011
	// TradeSystemNotifyTemplate  交易系统通知(比如:转账退回,红包退回)
	TradeSystemNotifyTemplate ContentType = 1012

	// ---------- 客服类 ----------
	HotlineAssignTo ContentType = 1200 // 分配客服
	HotlineSolved   ContentType = 1201 // 已解决
	HotlineReopen   ContentType = 1202 // 会话被重开

	// ---------- 音视频 ----------
	VideoCallResult ContentType = 9989 // 音视频通话结果
)

func (ContentType) Int

func (c ContentType) Int() int

Int Int

func (ContentType) String

func (c ContentType) String() string

type DeviceType

type DeviceType string

DeviceType 设备类型

const (
	// DeviceTypeIOS iOS设备
	DeviceTypeIOS DeviceType = "IOS"

	// DeviceTypeMI 小米设备
	DeviceTypeMI DeviceType = "MI"

	// DeviceTypeHMS 华为设备
	DeviceTypeHMS DeviceType = "HMS"

	// DeviceTypeOPPO oppo设备
	DeviceTypeOPPO DeviceType = "OPPO"

	// DeviceTypeVIVO vivo设备
	DeviceTypeVIVO DeviceType = "VIVO"
)

type GroupAllowViewHistoryMsgStatus

type GroupAllowViewHistoryMsgStatus int

GroupAllowViewHistoryMsgStatus 新成员是否能查看历史消息

const (
	// GroupAllowViewHistoryMsgDisabled 不能查看历史消息
	GroupAllowViewHistoryMsgDisabled GroupAllowViewHistoryMsgStatus = 0
	// GroupAllowViewHistoryMsgEnabled 能查看历史消息
	GroupAllowViewHistoryMsgEnabled GroupAllowViewHistoryMsgStatus = 1
)

type GroupMemberRole

type GroupMemberRole int

GroupMemberRole 群成员角色

const (
	// GroupMemberRoleCreater 群主
	GroupMemberRoleCreater GroupMemberRole = 1
	// GroupMemberRoleManager 管理员
	GroupMemberRoleManager GroupMemberRole = 2
	// GroupMemberRoleNormal 成员
	GroupMemberRoleNormal GroupMemberRole = 0
)

type GroupMemberStatus

type GroupMemberStatus int

GroupMemberStatus 群成员状态

const (
	// GroupMemberStatusNormal 正常
	GroupMemberStatusNormal GroupMemberStatus = 1
	// GroupMemberStatusBlacklist 黑名单
	GroupMemberStatusBlacklist GroupMemberStatus = 2
)

type MemoryCache

type MemoryCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemoryCache 内存缓存

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache 创建

func (*MemoryCache) Delete

func (m *MemoryCache) Delete(key string) error

Delete Delete

func (*MemoryCache) Get

func (m *MemoryCache) Get(key string) (string, error)

Get Get

func (*MemoryCache) Set

func (m *MemoryCache) Set(key string, value string) error

Set Set

func (*MemoryCache) SetAndExpire

func (m *MemoryCache) SetAndExpire(key string, value string, expire time.Duration) error

SetAndExpire SetAndExpire

type PageResult

type PageResult struct {
	PageIndex int64       `json:"page_index"` // 页码
	PageSize  int64       `json:"page_size"`  // 页大小
	Total     int64       `json:"total"`      // 数据总量
	Data      interface{} `json:"data"`       // 数据
}

PageResult 分页结果

func NewPageResult

func NewPageResult(pageIndex int64, pageSize int64, total int64, data interface{}) *PageResult

NewPageResult NewPageResult

type QRCodeModel

type QRCodeModel struct {
	Type QRCodeType             `json:"type"` // 二维码类型
	Data map[string]interface{} `json:"data"`
}

QRCodeModel QRCodeModel

func NewQRCodeModel

func NewQRCodeModel(typ QRCodeType, data map[string]interface{}) *QRCodeModel

NewQRCodeModel NewQRCodeModel

type QRCodeType

type QRCodeType string

QRCodeType 二维码类型

const (
	// QRCodeTypeGroup 群聊
	QRCodeTypeGroup QRCodeType = "group"
	// QRCodeTypeScanLogin 扫描登录
	QRCodeTypeScanLogin QRCodeType = "scanLogin"
)

func (QRCodeType) MarshalJSON

func (q QRCodeType) MarshalJSON() ([]byte, error)

MarshalJSON MarshalJSON

func (*QRCodeType) UnmarshalJSON

func (q *QRCodeType) UnmarshalJSON(b []byte) error

UnmarshalJSON UnmarshalJSON

type RTCCallType

type RTCCallType int
const (
	RTCCallTypeAudio RTCCallType = 0 // 语音通话
	RTCCallTypeVideo RTCCallType = 1 // 视频通话
)

type RTCResultType

type RTCResultType int
const (
	RTCResultTypeCancel RTCResultType = 0 // 取消通话
	RTCResultTypeHangup RTCResultType = 1 // 挂断通话
	RTCResultTypeMissed RTCResultType = 2 // 未接听
	RTCResultTypeRefuse RTCResultType = 3 // 拒绝接听
)

type RedisCache

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

RedisCache redis缓存

func NewRedisCache

func NewRedisCache(addr string, password string) *RedisCache

NewRedisCache 创建

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string) error

Delete 删除key

func (*RedisCache) Get

func (r *RedisCache) Get(key string) (string, error)

Get Get

func (*RedisCache) GetRedisConn

func (r *RedisCache) GetRedisConn() *redis.Conn

GetRedisConn 获取redis连接

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value string) error

Set Set

func (*RedisCache) SetAndExpire

func (r *RedisCache) SetAndExpire(key string, value string, expire time.Duration) error

SetAndExpire 包含过期时间

type ScanLoginStatus

type ScanLoginStatus string

ScanLoginStatus 扫码状态

const (
	// ScanLoginStatusExpired 二维码过期
	ScanLoginStatusExpired ScanLoginStatus = "expired"
	// ScanLoginStatusWaitScan 等待扫码
	ScanLoginStatusWaitScan ScanLoginStatus = "waitScan"
	// ScanLoginStatusScanned 已扫描
	ScanLoginStatusScanned ScanLoginStatus = "scanned"
	// ScanLoginStatusAuthed 已授权
	ScanLoginStatusAuthed ScanLoginStatus = "authed"
)

type UserStatus

type UserStatus int

UserStatus 用户状态

const (
	// UserAvailable 可用
	UserAvailable UserStatus = 1
	// UserDisable 禁用
	UserDisable UserStatus = 0
)

type VercodeType

type VercodeType int

VercodeType 加好友验证码类型

const (
	// User 搜索
	User VercodeType = 1
	// GroupMember 群成员
	GroupMember VercodeType = 2
	// QRCode 二维码
	QRCode VercodeType = 3
	// Friend 好友
	Friend VercodeType = 4
	// 手机联系人
	MailList VercodeType = 5
)

Jump to

Keyboard shortcuts

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