Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions group/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ func (a *api) CreateGroup(group *Group) (groupId string, err error) {
req.Notification = group.notification
req.MaxMemberNum = group.maxMemberNum
req.ApplyJoinOption = group.applyJoinOption
req.InviteJoinOption = group.inviteJoinOption

if data := group.GetAllCustomData(); data != nil {
req.AppDefinedData = make([]*customDataItem, 0, len(data))
Expand Down
76 changes: 47 additions & 29 deletions group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type (
// ApplyJoinOption 申请加群处理方式
ApplyJoinOption string

// InviteJoinOption 邀请加群处理方式
InviteJoinOption string

// ShutUpStatus 全员禁言状态
ShutUpStatus string
)
Expand All @@ -44,29 +47,34 @@ const (
ApplyJoinOptionNeedPermission ApplyJoinOption = "NeedPermission" // 需要验证
ApplyJoinOptionDisableApply ApplyJoinOption = "DisableApply" // 禁止加群

InviteJoinOptionFreeAccess InviteJoinOption = "FreeAccess" // 自由加入
InviteJoinOptionNeedPermission InviteJoinOption = "NeedPermission" // 需要验证
InviteJoinOptionDisableApply InviteJoinOption = "DisableApply" // 禁止加群

ShutUpStatusOn ShutUpStatus = "On" // 开启
ShutUpStatusOff ShutUpStatus = "Off" // 关闭
)

type Group struct {
err error
id string // 群ID
name string // 群名称
groupType Type // 群类型
owner string // 群主ID
introduction string // 群简介
notification string // 群公告
avatar string // 群头像
memberNum uint // 群成员数
maxMemberNum uint // 最大群成员数量
applyJoinOption string // 申请加群处理方式
members []*Member // 群成员
customData map[string]interface{} // 群自定义数据
createTime int64 // 群创建时间
lastInfoTime int64 // 最后群资料变更时间
lastMsgTime int64 // 群内最后一条消息的时间
nextMsgSeq int // 群内下一条消息的Seq
shutUpStatus string // 群全员禁言状态
err error
id string // 群ID
name string // 群名称
groupType Type // 群类型
owner string // 群主ID
introduction string // 群简介
notification string // 群公告
avatar string // 群头像
memberNum uint // 群成员数
maxMemberNum uint // 最大群成员数量
applyJoinOption string // 申请加群处理方式
inviteJoinOption string // 申请加群处理方式
members []*Member // 群成员
customData map[string]interface{} // 群自定义数据
createTime int64 // 群创建时间
lastInfoTime int64 // 最后群资料变更时间
lastMsgTime int64 // 群内最后一条消息的时间
nextMsgSeq int // 群内下一条消息的Seq
shutUpStatus string // 群全员禁言状态
}

func NewGroup(id ...string) *Group {
Expand Down Expand Up @@ -172,6 +180,16 @@ func (g *Group) GetApplyJoinOption() string {
return g.applyJoinOption
}

// SetInviteJoinOption 设置邀请加群选项
func (g *Group) SetInviteJoinOption(inviteJoinOption InviteJoinOption) {
g.inviteJoinOption = string(inviteJoinOption)
}

// GetInviteJoinOption 获取邀请加群选项
func (g *Group) GetInviteJoinOption() string {
return g.inviteJoinOption
}

// AddMembers 添加群成员
func (g *Group) AddMembers(member ...*Member) {
if g.members == nil {
Expand Down Expand Up @@ -321,17 +339,17 @@ func (g *Group) checkImportError() (err error) {

// 检测更新错误
func (g *Group) checkUpdateError() (err error) {
if err = g.checkNameArgError(); err != nil {
return
}

if err = g.checkIntroductionArgError(); err != nil {
return
}

if err = g.checkNotificationArgError(); err != nil {
return
}
// if err = g.checkNameArgError(); err != nil {
// return
// }
//
// if err = g.checkIntroductionArgError(); err != nil {
// return
// }
//
// if err = g.checkNotificationArgError(); err != nil {
// return
// }

return
}
Expand Down
23 changes: 12 additions & 11 deletions group/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,18 @@ type (

// 创建群(请求)
createGroupReq struct {
OwnerUserId string `json:"Owner_Account,omitempty"` // (选填)群主 ID(需是 已导入 的账号)。填写后自动添加到群成员中;如果不填,群没有群主
GroupId string `json:"GroupId,omitempty"` // (选填)为了使得群组 ID 更加简单,便于记忆传播,腾讯云支持 App 在通过 REST API 创建群组时 自定义群组 ID
Type Type `json:"Type"` // (必填)群组形态,包括 Public(陌生人社交群),Private(即 Work,好友工作群),ChatRoom(即 Meeting,会议群),AVChatRoom(直播群)
Name string `json:"Name"` // (必填)群名称,最长30字节,使用 UTF-8 编码,1个汉字占3个字节
Introduction string `json:"Introduction,omitempty"` // (选填)群简介,最长240字节,使用 UTF-8 编码,1个汉字占3个字节
Notification string `json:"Notification,omitempty"` // (选填)群公告,最长300字节,使用 UTF-8 编码,1个汉字占3个字节
FaceUrl string `json:"FaceUrl,omitempty"` // (选填)群头像 URL,最长100字节
MaxMemberNum uint `json:"MaxMemberCount,omitempty"` // (选填)最大群成员数量,缺省时的默认值:付费套餐包上限,例如体验版是20,如果升级套餐包,需按照修改群基础资料修改这个字段
ApplyJoinOption string `json:"ApplyJoinOption,omitempty"` // (选填)申请加群处理方式。包含 FreeAccess(自由加入),NeedPermission(需要验证),DisableApply(禁止加群),不填默认为 NeedPermission(需要验证) 仅当创建支持申请加群的 群组 时,该字段有效
AppDefinedData []*customDataItem `json:"AppDefinedData,omitempty"` // (选填)群组维度的自定义字段,默认情况是没有的,可以通过 即时通信 IM 控制台 进行配置,详情请参阅 自定义字段
MemberList []*memberItem `json:"MemberList,omitempty"` // (选填)初始群成员列表,最多100个;成员信息字段详情请参阅 群成员资料
OwnerUserId string `json:"Owner_Account,omitempty"` // (选填)群主 ID(需是 已导入 的账号)。填写后自动添加到群成员中;如果不填,群没有群主
GroupId string `json:"GroupId,omitempty"` // (选填)为了使得群组 ID 更加简单,便于记忆传播,腾讯云支持 App 在通过 REST API 创建群组时 自定义群组 ID
Type Type `json:"Type"` // (必填)群组形态,包括 Public(陌生人社交群),Private(即 Work,好友工作群),ChatRoom(即 Meeting,会议群),AVChatRoom(直播群)
Name string `json:"Name"` // (必填)群名称,最长30字节,使用 UTF-8 编码,1个汉字占3个字节
Introduction string `json:"Introduction,omitempty"` // (选填)群简介,最长240字节,使用 UTF-8 编码,1个汉字占3个字节
Notification string `json:"Notification,omitempty"` // (选填)群公告,最长300字节,使用 UTF-8 编码,1个汉字占3个字节
FaceUrl string `json:"FaceUrl,omitempty"` // (选填)群头像 URL,最长100字节
MaxMemberNum uint `json:"MaxMemberCount,omitempty"` // (选填)最大群成员数量,缺省时的默认值:付费套餐包上限,例如体验版是20,如果升级套餐包,需按照修改群基础资料修改这个字段
ApplyJoinOption string `json:"ApplyJoinOption,omitempty"` // (选填)申请加群处理方式。包含 FreeAccess(自由加入),NeedPermission(需要验证),DisableApply(禁止加群),不填默认为 NeedPermission(需要验证) 仅当创建支持申请加群的 群组 时,该字段有效
InviteJoinOption string `json:"InviteJoinOption,omitempty"` // (选填)邀请加群处理方式。包含 FreeAccess(自由加入),NeedPermission(需要验证),DisableApply(禁止加群),不填默认为 NeedPermission(需要验证) 仅当创建支持申请加群的 群组 时,该字段有效
AppDefinedData []*customDataItem `json:"AppDefinedData,omitempty"` // (选填)群组维度的自定义字段,默认情况是没有的,可以通过 即时通信 IM 控制台 进行配置,详情请参阅 自定义字段
MemberList []*memberItem `json:"MemberList,omitempty"` // (选填)初始群成员列表,最多100个;成员信息字段详情请参阅 群成员资料
}

// 创建群(响应)
Expand Down