Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6969d5e5f0 | |||
| b3a760641a | |||
| fdade6c04f |
2
go.mod
2
go.mod
@ -33,7 +33,6 @@ require (
|
|||||||
go.mongodb.org/mongo-driver v1.17.1
|
go.mongodb.org/mongo-driver v1.17.1
|
||||||
go.opentelemetry.io/otel/trace v1.31.0
|
go.opentelemetry.io/otel/trace v1.31.0
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
|
||||||
gorm.io/driver/mysql v1.5.7
|
gorm.io/driver/mysql v1.5.7
|
||||||
gorm.io/gen v0.3.26
|
gorm.io/gen v0.3.26
|
||||||
gorm.io/gorm v1.25.12
|
gorm.io/gorm v1.25.12
|
||||||
@ -150,7 +149,6 @@ require (
|
|||||||
golang.org/x/time v0.13.0
|
golang.org/x/time v0.13.0
|
||||||
golang.org/x/tools v0.24.0 // indirect
|
golang.org/x/tools v0.24.0 // indirect
|
||||||
google.golang.org/protobuf v1.35.1 // indirect
|
google.golang.org/protobuf v1.35.1 // indirect
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -754,8 +754,6 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
|
|||||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@ -764,8 +762,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
|
|||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
|
||||||
gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gitea.ddegame.cn/open/servicebase/pkg/common"
|
"gitea.ddegame.cn/open/servicebase/pkg/common"
|
||||||
@ -885,7 +886,7 @@ func (client *ImClient) CreateProGroup(tname, owner, announcement, avatar, msg s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GroupUpdate 更新群组
|
// GroupUpdate 更新群组
|
||||||
func (client *ImClient) GroupUpdate(ctx context.Context, id, operator_id, name, announcement, icon string) error {
|
func (client *ImClient) GroupUpdate(ctx context.Context, id, operator_id, name, announcement, icon, extension string) error {
|
||||||
url := "https://open.yunxinapi.com/im/v2.1/teams/" + id
|
url := "https://open.yunxinapi.com/im/v2.1/teams/" + id
|
||||||
httpMethod := "PATCH"
|
httpMethod := "PATCH"
|
||||||
header := client.generateJsonHeader()
|
header := client.generateJsonHeader()
|
||||||
@ -900,6 +901,9 @@ func (client *ImClient) GroupUpdate(ctx context.Context, id, operator_id, name,
|
|||||||
// "agree_mode": agree_mode, 邀请入群时是否需要被邀请人的同意。0(默认):需要被邀请人同意才能入群。1:不需要被邀请人同意,直接入群。
|
// "agree_mode": agree_mode, 邀请入群时是否需要被邀请人的同意。0(默认):需要被邀请人同意才能入群。1:不需要被邀请人同意,直接入群。
|
||||||
// "invite_mode": invite_mode, 邀请权限,即谁可以邀请他人入群。0(默认):群主和管理员。1:所有人。
|
// "invite_mode": invite_mode, 邀请权限,即谁可以邀请他人入群。0(默认):群主和管理员。1:所有人。
|
||||||
}
|
}
|
||||||
|
if len(extension) > 0 {
|
||||||
|
reqBody["extension"] = extension
|
||||||
|
}
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
bodyBytes, err := json.Marshal(reqBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
@ -930,7 +934,10 @@ func (client *ImClient) GroupTransfer(ctx context.Context, id, new_owner, extens
|
|||||||
"team_type": 1,
|
"team_type": 1,
|
||||||
"new_owner_account_id": new_owner,
|
"new_owner_account_id": new_owner,
|
||||||
"leave": 2,
|
"leave": 2,
|
||||||
"extension": extension,
|
// "extension": extension,
|
||||||
|
}
|
||||||
|
if len(extension) > 0 {
|
||||||
|
reqBody["extension"] = extension
|
||||||
}
|
}
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
bodyBytes, err := json.Marshal(reqBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -964,6 +971,9 @@ func (client *ImClient) GroupManagerAdd(ctx context.Context, id, operator_id, ex
|
|||||||
"operator_id": operator_id,
|
"operator_id": operator_id,
|
||||||
// "extension": extension,
|
// "extension": extension,
|
||||||
}
|
}
|
||||||
|
if len(extension) > 0 {
|
||||||
|
reqBody["extension"] = extension
|
||||||
|
}
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
bodyBytes, err := json.Marshal(reqBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
@ -987,7 +997,7 @@ func (client *ImClient) GroupManagerAdd(ctx context.Context, id, operator_id, ex
|
|||||||
|
|
||||||
// GroupManagerRemove
|
// GroupManagerRemove
|
||||||
func (client *ImClient) GroupManagerRemove(ctx context.Context, id, operator_id, extension string, managers []string) error {
|
func (client *ImClient) GroupManagerRemove(ctx context.Context, id, operator_id, extension string, managers []string) error {
|
||||||
url := "https://open.yunxinapi.com/im/v2.1/teams/" + id + "/actions/remove_manager"
|
_url := "https://open.yunxinapi.com/im/v2.1/teams/" + id + "/actions/remove_manager"
|
||||||
httpMethod := "DELETE"
|
httpMethod := "DELETE"
|
||||||
header := client.generateJsonHeader()
|
header := client.generateJsonHeader()
|
||||||
reqBody := map[string]any{
|
reqBody := map[string]any{
|
||||||
@ -996,16 +1006,19 @@ func (client *ImClient) GroupManagerRemove(ctx context.Context, id, operator_id,
|
|||||||
"operator_id": operator_id,
|
"operator_id": operator_id,
|
||||||
// "extension": extension,
|
// "extension": extension,
|
||||||
}
|
}
|
||||||
// var params []string
|
if len(extension) > 0 {
|
||||||
// for k, v := range reqBody {
|
reqBody["extension"] = url.PathEscape(extension)
|
||||||
// params = append(params, fmt.Sprintf("%s=%v", k, v))
|
|
||||||
// }
|
|
||||||
// url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithStack(err)
|
|
||||||
}
|
}
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, string(bodyBytes))
|
var params []string
|
||||||
|
for k, v := range reqBody {
|
||||||
|
params = append(params, fmt.Sprintf("%s=%v", k, v))
|
||||||
|
}
|
||||||
|
_url = fmt.Sprintf("%s?%s", _url, strings.Join(params, "&"))
|
||||||
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
|
// if err != nil {
|
||||||
|
// return errors.WithStack(err)
|
||||||
|
// }
|
||||||
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.InfoF("GroupManagerRemove %s:"+err.Error(), operator_id)
|
log.InfoF("GroupManagerRemove %s:"+err.Error(), operator_id)
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
@ -1017,14 +1030,14 @@ func (client *ImClient) GroupManagerRemove(ctx context.Context, id, operator_id,
|
|||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
if body.Code != 200 {
|
if body.Code != 200 {
|
||||||
return errors.Errorf("GroupManagerRemove code(%d) not 200 url=%s id=%s operator=%s managers=%v,msg: %s", body.Code, url, id, operator_id, managers, body.Msg)
|
return errors.Errorf("GroupManagerRemove code(%d) not 200 url=%s id=%s operator=%s managers=%v,msg: %s", body.Code, _url, id, operator_id, managers, body.Msg)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupRemove
|
// GroupRemove
|
||||||
func (client *ImClient) GroupRemove(ctx context.Context, id, operator_id, extension string) error {
|
func (client *ImClient) GroupRemove(ctx context.Context, id, operator_id, extension string) error {
|
||||||
url := "https://open.yunxinapi.com/im/v2.1/teams/" + id
|
_url := "https://open.yunxinapi.com/im/v2.1/teams/" + id
|
||||||
httpMethod := "DELETE"
|
httpMethod := "DELETE"
|
||||||
header := client.generateJsonHeader()
|
header := client.generateJsonHeader()
|
||||||
reqBody := map[string]any{
|
reqBody := map[string]any{
|
||||||
@ -1032,16 +1045,19 @@ func (client *ImClient) GroupRemove(ctx context.Context, id, operator_id, extens
|
|||||||
"operator_id": operator_id,
|
"operator_id": operator_id,
|
||||||
// "extension": extension,
|
// "extension": extension,
|
||||||
}
|
}
|
||||||
|
if len(extension) > 0 {
|
||||||
|
reqBody["extension"] = url.PathEscape(extension)
|
||||||
|
}
|
||||||
var params []string
|
var params []string
|
||||||
for k, v := range reqBody {
|
for k, v := range reqBody {
|
||||||
params = append(params, fmt.Sprintf("%s=%v", k, v))
|
params = append(params, fmt.Sprintf("%s=%v", k, v))
|
||||||
}
|
}
|
||||||
url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
_url = fmt.Sprintf("%s?%s", _url, strings.Join(params, "&"))
|
||||||
// bodyBytes, err := json.Marshal(reqBody)
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return errors.WithStack(err)
|
// return errors.WithStack(err)
|
||||||
// }
|
// }
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, "")
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.InfoF("GroupRemove %s:"+err.Error(), operator_id)
|
log.InfoF("GroupRemove %s:"+err.Error(), operator_id)
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
@ -1060,26 +1076,29 @@ func (client *ImClient) GroupRemove(ctx context.Context, id, operator_id, extens
|
|||||||
|
|
||||||
// GroupMemberKick
|
// GroupMemberKick
|
||||||
func (client *ImClient) GroupMemberKick(ctx context.Context, tid, operator_id, extension string, members []string) error {
|
func (client *ImClient) GroupMemberKick(ctx context.Context, tid, operator_id, extension string, members []string) error {
|
||||||
url := "https://open.yunxinapi.com/im/v2/team_members/actions/kick_member"
|
_url := "https://open.yunxinapi.com/im/v2/team_members/actions/kick_member"
|
||||||
httpMethod := "DELETE"
|
httpMethod := "DELETE"
|
||||||
header := client.generateJsonHeader()
|
header := client.generateJsonHeader()
|
||||||
reqBody := map[string]any{
|
reqBody := map[string]any{
|
||||||
"team_type": 1,
|
"team_type": 1,
|
||||||
"operator_id": operator_id,
|
"operator_id": operator_id,
|
||||||
"team_id": tools.StrToInt(tid),
|
"team_id": tools.StrToInt64(tid),
|
||||||
"kick_account_ids": members,
|
"kick_account_ids": members,
|
||||||
// "extension": extension,
|
// "extension": extension,
|
||||||
}
|
}
|
||||||
|
if len(extension) > 0 {
|
||||||
|
reqBody["extension"] = url.PathEscape(extension)
|
||||||
|
}
|
||||||
var params []string
|
var params []string
|
||||||
for k, v := range reqBody {
|
for k, v := range reqBody {
|
||||||
params = append(params, fmt.Sprintf("%s=%v", k, v))
|
params = append(params, fmt.Sprintf("%s=%v", k, v))
|
||||||
}
|
}
|
||||||
url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
_url = fmt.Sprintf("%s?%s", _url, strings.Join(params, "&"))
|
||||||
// bodyBytes, err := json.Marshal(reqBody)
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return errors.WithStack(err)
|
// return errors.WithStack(err)
|
||||||
// }
|
// }
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, "")
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.InfoF("GroupMemberKick %s:"+err.Error(), operator_id)
|
log.InfoF("GroupMemberKick %s:"+err.Error(), operator_id)
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
@ -1098,25 +1117,28 @@ func (client *ImClient) GroupMemberKick(ctx context.Context, tid, operator_id, e
|
|||||||
|
|
||||||
// GroupMemberLeave
|
// GroupMemberLeave
|
||||||
func (client *ImClient) GroupMemberLeave(ctx context.Context, tid, account_id, extension string) error {
|
func (client *ImClient) GroupMemberLeave(ctx context.Context, tid, account_id, extension string) error {
|
||||||
url := "https://open.yunxinapi.com/im/v2/team_members/actions/leave"
|
_url := "https://open.yunxinapi.com/im/v2/team_members/actions/leave"
|
||||||
httpMethod := "DELETE"
|
httpMethod := "DELETE"
|
||||||
header := client.generateJsonHeader()
|
header := client.generateJsonHeader()
|
||||||
reqBody := map[string]any{
|
reqBody := map[string]any{
|
||||||
"team_type": 1,
|
"team_type": 1,
|
||||||
"account_id": account_id,
|
"account_id": account_id,
|
||||||
"team_id": tools.StrToInt(tid),
|
"team_id": tid,
|
||||||
// "extension": extension,
|
// "extension": extension,
|
||||||
}
|
}
|
||||||
|
if len(extension) > 0 {
|
||||||
|
reqBody["extension"] = url.PathEscape(extension)
|
||||||
|
}
|
||||||
var params []string
|
var params []string
|
||||||
for k, v := range reqBody {
|
for k, v := range reqBody {
|
||||||
params = append(params, fmt.Sprintf("%s=%v", k, v))
|
params = append(params, fmt.Sprintf("%s=%v", k, v))
|
||||||
}
|
}
|
||||||
url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
_url = fmt.Sprintf("%s?%s", _url, strings.Join(params, "&"))
|
||||||
// bodyBytes, err := json.Marshal(reqBody)
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return errors.WithStack(err)
|
// return errors.WithStack(err)
|
||||||
// }
|
// }
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, "")
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.InfoF("GroupMemberLeave %s:"+err.Error(), tid)
|
log.InfoF("GroupMemberLeave %s:"+err.Error(), tid)
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
@ -1141,10 +1163,13 @@ func (client *ImClient) GroupMemberJoin(ctx context.Context, tid, operator_id, m
|
|||||||
reqBody := map[string]any{
|
reqBody := map[string]any{
|
||||||
"team_type": 1,
|
"team_type": 1,
|
||||||
"operator_id": operator_id,
|
"operator_id": operator_id,
|
||||||
"team_id": tools.StrToInt(tid),
|
"team_id": tools.StrToInt64(tid),
|
||||||
"msg": msg,
|
"msg": msg,
|
||||||
"invite_account_ids": invite_account_ids,
|
"invite_account_ids": invite_account_ids,
|
||||||
"extension": extension,
|
// "extension": extension,
|
||||||
|
}
|
||||||
|
if len(extension) > 0 {
|
||||||
|
reqBody["extension"] = extension
|
||||||
}
|
}
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
bodyBytes, err := json.Marshal(reqBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user