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
+16
View File
@@ -1 +1,17 @@
package call_back_struct
type CommonCallbackReq struct {
CallbackCommand string `json:"callbackCommand"`
ServerMsgID string `json:"serverID"`
ClientID string `json:"clientID"`
OperationID string `json:"operationID"`
}
type CommonCallbackResp struct {
ActionCode int `json:"actionCode"`
ErrCode int `json:"errCode"`
ErrMsg string `json:"errMsg"`
OperationID string `json:"operationID"`
}
+9
View File
@@ -0,0 +1,9 @@
package call_back_struct
type CallbackBeforeCreateGroupReq struct {
CommonCallbackReq
}
type CallbackAfterCreateGroupResp struct {
CommonCallbackResp
}
+60
View File
@@ -1 +1,61 @@
package call_back_struct
type singleMsg struct {
SendID string `json:"sendID"`
RecvID string `json:"recvID"`
ClientMsgID string `json:"clientMsgID"`
ServerMsgID string `json:"serverMsgId"`
SendTime int64 `json:"sendTime"`
CreateTime int64 `json:"createTime"`
}
type CallbackBeforeSendSingleMsgReq struct {
CommonCallbackReq
singleMsg
}
type CallbackBeforeSendSingleMsgResp struct {
CommonCallbackResp
}
type CallbackAfterSendSingleMsgReq struct {
CommonCallbackReq
singleMsg
}
type CallbackAfterSendSingleMsgResp struct {
CommonCallbackResp
}
type groupMsg struct {
}
type CallbackBeforeSendGroupMsgReq struct {
CommonCallbackReq
}
type CallbackBeforeSendGroupMsgResp struct {
CommonCallbackResp
}
type CallbackAfterSendGroupMsgReq struct {
CommonCallbackReq
}
type CallbackAfterSendGroupMsgResp struct {
CommonCallbackResp
}
type CallBackWordFilterReq struct {
CommonCallbackReq
Content []byte `json:"content"`
SendID string `json:"SendID"`
RecvID string `json:"RecvID"`
GroupID string `json:"GroupID"`
}
type CallBackWordFilterResp struct {
CommonCallbackResp
Content []byte `json:"content"`
}
+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",
+30
View File
@@ -338,6 +338,36 @@ message ConversationUpdateTips{
}
///callback
message CommonCallbackURLReq {
string CallbackCommand = 1 [json_name = "code"];
string OpenIMServerID = 2;
string OperationID = 3;
}
message CommonCallbackURLResp {
string Code = 1 [json_name = "code"];
string Msg = 2 [json_name = "msg"];
string OperationID = 3 [json_name = "operationID"];
}
message CallbackBeforeSendMsgReq {
commonReq CommonCallbackURLReq = 1;
}
message CallbackBeforeSendMsgResp {
commonResp CommonCallbackURLResp = 1;
string FromUserID = 2;
}
message CallbackAfterAddFriendReq {
commonReq CommonCallbackURLReq = 1;
}
message CallbackAfterAddFriendResp {
commonResp CommonCallbackURLResp = 1;
}
///cms