mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 11:36:44 +08:00
del files
This commit is contained in:
parent
51529eece3
commit
40438f529a
@ -40,7 +40,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
|
|||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOfflinePushCommand, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOfflinePushCommand, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
callbackResp.ErrMsg = err.Error()
|
callbackResp.ErrMsg = err.Error()
|
||||||
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
|
if !*config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
|
||||||
callbackResp.ActionCode = constant.ActionForbidden
|
callbackResp.ActionCode = constant.ActionForbidden
|
||||||
return callbackResp
|
return callbackResp
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,7 +35,7 @@ func callbackBeforeCreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq)
|
|||||||
//utils.CopyStructFields(req, msg.MsgData)
|
//utils.CopyStructFields(req, msg.MsgData)
|
||||||
defer log.NewDebug(req.OperationID, utils.GetSelfFuncName(), commonCallbackReq, *resp)
|
defer log.NewDebug(req.OperationID, utils.GetSelfFuncName(), commonCallbackReq, *resp)
|
||||||
err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq,
|
err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq,
|
||||||
resp, config.Config.Callback.CallbackBeforeCreateGroup.CallbackTimeOut, &config.Config.Callback.CallbackBeforeCreateGroup.CallbackFailedContinue)
|
resp, config.Config.Callback.CallbackBeforeCreateGroup)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if resp.GroupID != nil {
|
if resp.GroupID != nil {
|
||||||
req.GroupInfo.GroupID = *resp.GroupID
|
req.GroupInfo.GroupID = *resp.GroupID
|
||||||
@ -98,7 +98,7 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, grou
|
|||||||
CommonCallbackResp: &callbackResp,
|
CommonCallbackResp: &callbackResp,
|
||||||
}
|
}
|
||||||
err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeMemberJoinGroupCommand, callbackReq,
|
err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeMemberJoinGroupCommand, callbackReq,
|
||||||
resp, config.Config.Callback.CallbackBeforeMemberJoinGroup.CallbackTimeOut, &config.Config.Callback.CallbackBeforeMemberJoinGroup.CallbackFailedContinue)
|
resp, config.Config.Callback.CallbackBeforeMemberJoinGroup)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if resp.MuteEndTime != nil {
|
if resp.MuteEndTime != nil {
|
||||||
groupMember.MuteEndTime = utils.UnixSecondToTime(*resp.MuteEndTime)
|
groupMember.MuteEndTime = utils.UnixSecondToTime(*resp.MuteEndTime)
|
||||||
|
@ -20,10 +20,10 @@ const ConfName = "openIMConf"
|
|||||||
|
|
||||||
var Config config
|
var Config config
|
||||||
|
|
||||||
type callBackConfig struct {
|
type CallBackConfig struct {
|
||||||
Enable bool `yaml:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
CallbackTimeOut int `yaml:"callbackTimeOut"`
|
CallbackTimeOut int `yaml:"callbackTimeOut"`
|
||||||
CallbackFailedContinue bool `yaml:"callbackFailedContinue"`
|
CallbackFailedContinue *bool `yaml:"callbackFailedContinue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
@ -283,21 +283,21 @@ type config struct {
|
|||||||
|
|
||||||
Callback struct {
|
Callback struct {
|
||||||
CallbackUrl string `yaml:"callbackUrl"`
|
CallbackUrl string `yaml:"callbackUrl"`
|
||||||
CallbackBeforeSendSingleMsg callBackConfig `yaml:"callbackBeforeSendSingleMsg"`
|
CallbackBeforeSendSingleMsg CallBackConfig `yaml:"callbackBeforeSendSingleMsg"`
|
||||||
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
CallbackAfterSendSingleMsg CallBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
||||||
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
CallbackBeforeSendGroupMsg CallBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
||||||
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
CallbackAfterSendGroupMsg CallBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
||||||
CallbackMsgModify callBackConfig `yaml:"callbackMsgModify"`
|
CallbackMsgModify CallBackConfig `yaml:"callbackMsgModify"`
|
||||||
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
CallbackUserOnline CallBackConfig `yaml:"callbackUserOnline"`
|
||||||
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
CallbackUserOffline CallBackConfig `yaml:"callbackUserOffline"`
|
||||||
CallbackUserKickOff callBackConfig `yaml:"callbackUserKickOff"`
|
CallbackUserKickOff CallBackConfig `yaml:"callbackUserKickOff"`
|
||||||
CallbackOfflinePush callBackConfig `yaml:"callbackOfflinePush"`
|
CallbackOfflinePush CallBackConfig `yaml:"callbackOfflinePush"`
|
||||||
CallbackOnlinePush callBackConfig `yaml:"callbackOnlinePush"`
|
CallbackOnlinePush CallBackConfig `yaml:"callbackOnlinePush"`
|
||||||
CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"`
|
CallbackBeforeSuperGroupOnlinePush CallBackConfig `yaml:"callbackSuperGroupOnlinePush"`
|
||||||
CallbackBeforeAddFriend callBackConfig `yaml:"callbackBeforeAddFriend"`
|
CallbackBeforeAddFriend CallBackConfig `yaml:"callbackBeforeAddFriend"`
|
||||||
CallbackBeforeCreateGroup callBackConfig `yaml:"callbackBeforeCreateGroup"`
|
CallbackBeforeCreateGroup CallBackConfig `yaml:"callbackBeforeCreateGroup"`
|
||||||
CallbackBeforeMemberJoinGroup callBackConfig `yaml:"callbackBeforeMemberJoinGroup"`
|
CallbackBeforeMemberJoinGroup CallBackConfig `yaml:"callbackBeforeMemberJoinGroup"`
|
||||||
CallbackBeforeSetGroupMemberInfo callBackConfig `yaml:"callbackBeforeSetGroupMemberInfo"`
|
CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"callbackBeforeSetGroupMemberInfo"`
|
||||||
} `yaml:"callback"`
|
} `yaml:"callback"`
|
||||||
Notification struct {
|
Notification struct {
|
||||||
///////////////////////group/////////////////////////////
|
///////////////////////group/////////////////////////////
|
||||||
@ -640,8 +640,8 @@ func unmarshalConfig(config interface{}, configPath string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initConfig(config interface{}, configName, configPath string) {
|
func initConfig(config interface{}, configName, configPath string) {
|
||||||
var env string
|
|
||||||
if configPath == "" {
|
if configPath == "" {
|
||||||
|
var env string
|
||||||
if configName == "config.yaml" {
|
if configName == "config.yaml" {
|
||||||
env = "CONFIG_NAME"
|
env = "CONFIG_NAME"
|
||||||
} else if configName == "usualConfig.yaml" {
|
} else if configName == "usualConfig.yaml" {
|
||||||
@ -649,32 +649,17 @@ func initConfig(config interface{}, configName, configPath string) {
|
|||||||
}
|
}
|
||||||
cfgName := os.Getenv(env)
|
cfgName := os.Getenv(env)
|
||||||
if len(cfgName) != 0 {
|
if len(cfgName) != 0 {
|
||||||
bytes, err := ioutil.ReadFile(filepath.Join(cfgName, "config", configName))
|
configPath = filepath.Join(cfgName, "config", configName)
|
||||||
if err != nil {
|
_, err := os.Stat(configPath)
|
||||||
bytes, err = ioutil.ReadFile(filepath.Join(Root, "config", configName))
|
if os.IsNotExist(err) {
|
||||||
if err != nil {
|
configPath = filepath.Join(Root, "config", configName)
|
||||||
panic(err.Error() + " config: " + filepath.Join(cfgName, "config", configName))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Root = cfgName
|
Root = cfgName
|
||||||
}
|
}
|
||||||
if err = yaml.Unmarshal(bytes, config); err != nil {
|
|
||||||
panic(err.Error())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
} else {
|
} else {
|
||||||
bytes, err := ioutil.ReadFile(fmt.Sprintf("../config/%s", configName))
|
configPath = fmt.Sprintf("../config/%s", configName)
|
||||||
if err != nil {
|
|
||||||
panic(err.Error() + configName)
|
|
||||||
}
|
|
||||||
if err = yaml.Unmarshal(bytes, config); err != nil {
|
|
||||||
panic(err.Error())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unmarshalConfig(config, configPath)
|
unmarshalConfig(config, configPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,11 +730,9 @@ func InitConfig(configPath string) {
|
|||||||
if Config.Push.Getui.Enable == nil {
|
if Config.Push.Getui.Enable == nil {
|
||||||
Config.Push.Getui.Enable = &UsualConfig.Push.Getui.Enable
|
Config.Push.Getui.Enable = &UsualConfig.Push.Getui.Enable
|
||||||
}
|
}
|
||||||
|
|
||||||
if Config.Secret == "" {
|
if Config.Secret == "" {
|
||||||
Config.Secret = UsualConfig.Secret
|
Config.Secret = UsualConfig.Secret
|
||||||
}
|
}
|
||||||
|
|
||||||
if Config.TokenPolicy.AccessExpire == 0 {
|
if Config.TokenPolicy.AccessExpire == 0 {
|
||||||
Config.TokenPolicy.AccessExpire = UsualConfig.Tokenpolicy.AccessExpire
|
Config.TokenPolicy.AccessExpire = UsualConfig.Tokenpolicy.AccessExpire
|
||||||
}
|
}
|
||||||
@ -759,81 +742,5 @@ func InitConfig(configPath string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
initConfig(&Config, "config.yaml", "")
|
InitConfig("")
|
||||||
initConfig(&UsualConfig, "usualConfig.yaml", "")
|
|
||||||
if Config.Etcd.UserName == "" {
|
|
||||||
Config.Etcd.UserName = UsualConfig.Etcd.UserName
|
|
||||||
}
|
|
||||||
if Config.Etcd.Password == "" {
|
|
||||||
Config.Etcd.Password = UsualConfig.Etcd.Password
|
|
||||||
}
|
|
||||||
if Config.Etcd.Secret == "" {
|
|
||||||
Config.Etcd.Secret = UsualConfig.Etcd.Secret
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.Mysql.DBUserName == "" {
|
|
||||||
Config.Mysql.DBUserName = UsualConfig.Mysql.DBUserName
|
|
||||||
}
|
|
||||||
if Config.Mysql.DBPassword == "" {
|
|
||||||
Config.Mysql.DBPassword = UsualConfig.Mysql.DBPassword
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.Redis.DBUserName == "" {
|
|
||||||
Config.Redis.DBUserName = UsualConfig.Redis.DBUserName
|
|
||||||
}
|
|
||||||
if Config.Redis.DBPassWord == "" {
|
|
||||||
Config.Redis.DBPassWord = UsualConfig.Redis.DBPassword
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.Mongo.DBUserName == "" {
|
|
||||||
Config.Mongo.DBUserName = UsualConfig.Mongo.DBUserName
|
|
||||||
}
|
|
||||||
if Config.Mongo.DBPassword == "" {
|
|
||||||
Config.Mongo.DBPassword = UsualConfig.Mongo.DBPassword
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.Kafka.SASLUserName == "" {
|
|
||||||
Config.Kafka.SASLUserName = UsualConfig.Kafka.SASLUserName
|
|
||||||
}
|
|
||||||
if Config.Kafka.SASLPassword == "" {
|
|
||||||
Config.Kafka.SASLPassword = UsualConfig.Kafka.SASLPassword
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.Credential.Minio.AccessKeyID == "" {
|
|
||||||
Config.Credential.Minio.AccessKeyID = UsualConfig.Credential.Minio.AccessKeyID
|
|
||||||
}
|
|
||||||
if Config.Credential.Minio.SecretAccessKey == "" {
|
|
||||||
Config.Credential.Minio.SecretAccessKey = UsualConfig.Credential.Minio.SecretAccessKey
|
|
||||||
}
|
|
||||||
if Config.Credential.Minio.Endpoint == "" {
|
|
||||||
Config.Credential.Minio.Endpoint = UsualConfig.Credential.Minio.Endpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.MessageVerify.FriendVerify == nil {
|
|
||||||
Config.MessageVerify.FriendVerify = &UsualConfig.Messageverify.FriendVerify
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.Push.Getui.MasterSecret == "" {
|
|
||||||
Config.Push.Getui.MasterSecret = UsualConfig.Push.Getui.MasterSecret
|
|
||||||
}
|
|
||||||
if Config.Push.Getui.AppKey == "" {
|
|
||||||
Config.Push.Getui.AppKey = UsualConfig.Push.Getui.AppKey
|
|
||||||
}
|
|
||||||
if Config.Push.Getui.PushUrl == "" {
|
|
||||||
Config.Push.Getui.PushUrl = UsualConfig.Push.Getui.PushUrl
|
|
||||||
}
|
|
||||||
if Config.Push.Getui.Enable == nil {
|
|
||||||
Config.Push.Getui.Enable = &UsualConfig.Push.Getui.Enable
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.Secret == "" {
|
|
||||||
Config.Secret = UsualConfig.Secret
|
|
||||||
}
|
|
||||||
|
|
||||||
if Config.TokenPolicy.AccessExpire == 0 {
|
|
||||||
Config.TokenPolicy.AccessExpire = UsualConfig.Tokenpolicy.AccessExpire
|
|
||||||
}
|
|
||||||
if Config.TokenPolicy.AccessSecret == "" {
|
|
||||||
Config.TokenPolicy.AccessSecret = UsualConfig.Tokenpolicy.AccessSecret
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
cbApi "Open_IM/pkg/callback_struct"
|
cbApi "Open_IM/pkg/callback_struct"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -58,19 +59,19 @@ func Post(url string, data interface{}, timeOutSecond int) (content []byte, err
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallBackPostReturn(url, callbackCommand string, input interface{}, output cbApi.CallbackResp, timeOut int, failedContinue *bool) error {
|
func CallBackPostReturn(url, callbackCommand string, input interface{}, output cbApi.CallbackResp, callbackConfig config.CallBackConfig) error {
|
||||||
v := urlLib.Values{}
|
v := urlLib.Values{}
|
||||||
v.Set("callbackCommand", callbackCommand)
|
v.Set("callbackCommand", callbackCommand)
|
||||||
url = url + "?" + v.Encode()
|
url = url + "?" + v.Encode()
|
||||||
b, err := Post(url, input, timeOut)
|
b, err := Post(url, input, callbackConfig.CallbackTimeOut)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if failedContinue != nil && *failedContinue {
|
if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue {
|
||||||
return constant.ErrCallbackContinue
|
return constant.ErrCallbackContinue
|
||||||
}
|
}
|
||||||
return constant.NewErrNetwork(err)
|
return constant.NewErrNetwork(err)
|
||||||
}
|
}
|
||||||
if err = json.Unmarshal(b, output); err != nil {
|
if err = json.Unmarshal(b, output); err != nil {
|
||||||
if failedContinue != nil && *failedContinue {
|
if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue {
|
||||||
return constant.ErrCallbackContinue
|
return constant.ErrCallbackContinue
|
||||||
}
|
}
|
||||||
return constant.NewErrData(err)
|
return constant.NewErrData(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user