feat(app): update
This commit is contained in:
@ -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"
|
||||||
@ -996,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{
|
||||||
@ -1006,18 +1007,18 @@ func (client *ImClient) GroupManagerRemove(ctx context.Context, id, operator_id,
|
|||||||
// "extension": extension,
|
// "extension": extension,
|
||||||
}
|
}
|
||||||
if len(extension) > 0 {
|
if len(extension) > 0 {
|
||||||
reqBody["extension"] = extension
|
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, "&"))
|
||||||
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
|
// if err != nil {
|
||||||
|
// return errors.WithStack(err)
|
||||||
// }
|
// }
|
||||||
// url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithStack(err)
|
|
||||||
}
|
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, string(bodyBytes))
|
|
||||||
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)
|
||||||
@ -1029,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{
|
||||||
@ -1045,18 +1046,18 @@ func (client *ImClient) GroupRemove(ctx context.Context, id, operator_id, extens
|
|||||||
// "extension": extension,
|
// "extension": extension,
|
||||||
}
|
}
|
||||||
if len(extension) > 0 {
|
if len(extension) > 0 {
|
||||||
reqBody["extension"] = extension
|
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, "&"))
|
||||||
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
|
// if err != nil {
|
||||||
|
// return errors.WithStack(err)
|
||||||
// }
|
// }
|
||||||
// url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithStack(err)
|
|
||||||
}
|
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, string(bodyBytes))
|
|
||||||
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)
|
||||||
@ -1075,29 +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 {
|
if len(extension) > 0 {
|
||||||
reqBody["extension"] = extension
|
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, "&"))
|
||||||
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
|
// if err != nil {
|
||||||
|
// return errors.WithStack(err)
|
||||||
// }
|
// }
|
||||||
// url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithStack(err)
|
|
||||||
}
|
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, string(bodyBytes))
|
|
||||||
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)
|
||||||
@ -1116,28 +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 {
|
if len(extension) > 0 {
|
||||||
reqBody["extension"] = extension
|
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, "&"))
|
||||||
|
// bodyBytes, err := json.Marshal(reqBody)
|
||||||
|
// if err != nil {
|
||||||
|
// return errors.WithStack(err)
|
||||||
// }
|
// }
|
||||||
// url = fmt.Sprintf("%s?%s", url, strings.Join(params, "&"))
|
res, err := HyTools.HttpDo(httpMethod, _url, header, "")
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithStack(err)
|
|
||||||
}
|
|
||||||
res, err := HyTools.HttpDo(httpMethod, url, header, string(bodyBytes))
|
|
||||||
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)
|
||||||
@ -1162,7 +1163,7 @@ 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,
|
||||||
|
|||||||
Reference in New Issue
Block a user