merge code

This commit is contained in:
wangchuxiao
2022-02-28 17:57:03 +08:00
parent 7d8d314962
commit 0bed7ee669
20 changed files with 341 additions and 57 deletions
+15 -5
View File
@@ -19,6 +19,12 @@ var (
var Config config
type callBackConfig struct {
Enable bool `yaml:"enable"`
CallbackTimeOut int `yaml:"callbackTimeOut"`
CallbackFailedContinue bool `CallbackFailedContinue`
}
type config struct {
ServerIP string `yaml:"serverip"`
ServerVersion string `yaml:"serverversion"`
@@ -167,11 +173,6 @@ type config struct {
AccessSecret string `yaml:"accessSecret"`
AccessExpire int64 `yaml:"accessExpire"`
}
MessageCallBack struct {
CallbackSwitch bool `yaml:"callbackSwitch"`
CallbackUrl string `yaml:"callbackUrl"`
CallBackTimeOut int `yaml:"callbackTimeOut"`
}
MessageJudge struct {
IsJudgeFriend bool `yaml:"isJudgeFriend"`
}
@@ -179,6 +180,15 @@ type config struct {
PushSound string `yaml:"pushSound"`
BadgeCount bool `yaml:"badgeCount"`
}
Callback struct {
CallbackUrl string `yaml:"callbackUrl"`
CallbackbeforeSendSingleMsg callBackConfig `yaml:"callbackSendGroupMsg"`
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackSendSingleMsg"`
CallbackBeforeSendGroupMsg callBackConfig `yaml:"CallbackBeforeSendGroupMsg"`
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
} `yaml:"callback"`
Notification struct {
///////////////////////group/////////////////////////////
GroupCreated struct {
+10
View File
@@ -136,6 +136,16 @@ const (
VerificationCodeForReset = 2
VerificationCodeForRegisterSuffix = "_forRegister"
VerificationCodeForResetSuffix = "_forReset"
//callbackCommand
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsg"
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsg"
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsg"
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
CallbackWordFilterCommand = "callbackWordFilterCommand"
//actionCode
ActionAllow = 0
ActionForbidden = 1
)
var ContentType2PushContent = map[int64]string{
+2
View File
@@ -51,6 +51,7 @@ var (
ErrAccess = ErrInfo{ErrCode: 801, ErrMsg: AccessMsg.Error()}
ErrDB = ErrInfo{ErrCode: 802, ErrMsg: DBMsg.Error()}
ErrArgs = ErrInfo{ErrCode: 8003, ErrMsg: ArgsMsg.Error()}
ErrCallback = ErrInfo{ErrCode: 809, ErrMsg: CallBackMsg.Error()}
)
var (
@@ -64,6 +65,7 @@ var (
AccessMsg = errors.New("no permission")
DBMsg = errors.New("db failed")
ArgsMsg = errors.New("args failed")
CallBackMsg = errors.New("callback failed")
ThirdPartyMsg = errors.New("third party error")
)
+10
View File
@@ -53,3 +53,13 @@ func Post(url string, data interface{}, timeOutSecond int) (content []byte, err
}
return result, nil
}
func PostReturn(url string, input, output interface{}, timeOut int) error {
b, err := Post(url, input, timeOut)
if err != nil {
return err
}
if err = json.Unmarshal(b, output); err != nil {
return err
}
}
+7 -8
View File
@@ -2,7 +2,6 @@ package log
import (
"Open_IM/pkg/common/config"
"bufio"
"fmt"
"os"
"time"
@@ -33,13 +32,13 @@ func loggerInit(moduleName string) *Logger {
//All logs will be printed
logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel))
//Close std console output
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
if err != nil {
panic(err.Error())
}
writer := bufio.NewWriter(src)
logger.SetOutput(writer)
//logger.SetOutput(os.Stdout)
//src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
//if err != nil {
// panic(err.Error())
//}
//writer := bufio.NewWriter(src)
//logger.SetOutput(writer)
logger.SetOutput(os.Stdout)
//Log Console Print Style Setting
logger.SetFormatter(&nested.Formatter{
TimestampFormat: "2006-01-02 15:04:05.000",