mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 10:35:59 +08:00
merge code
This commit is contained in:
+20
-19
@@ -172,112 +172,112 @@ type config struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"groupCreated"`
|
||||
|
||||
GroupInfoSet struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"groupInfoSet"`
|
||||
|
||||
JoinGroupApplication struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"joinGroupApplication"`
|
||||
|
||||
MemberQuit struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"memberQuit"`
|
||||
|
||||
GroupApplicationAccepted struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"groupApplicationAccepted"`
|
||||
|
||||
GroupApplicationRejected struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"groupApplicationRejected"`
|
||||
|
||||
GroupOwnerTransferred struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"groupOwnerTransferred"`
|
||||
|
||||
MemberKicked struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"memberKicked"`
|
||||
|
||||
MemberInvited struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"memberInvited"`
|
||||
|
||||
MemberEnter struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"memberEnter"`
|
||||
////////////////////////user///////////////////////
|
||||
UserInfoUpdated struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"userInfoUpdated"`
|
||||
|
||||
//////////////////////friend///////////////////////
|
||||
FriendApplication struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"friendApplicationAdded"`
|
||||
FriendApplicationApproved struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"friendApplicationApproved"`
|
||||
|
||||
FriendApplicationRejected struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"friendApplicationRejected"`
|
||||
|
||||
FriendAdded struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"friendAdded"`
|
||||
|
||||
FriendDeleted struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"friendDeleted"`
|
||||
FriendRemarkSet struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"friendRemarkSet"`
|
||||
BlackAdded struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"blackAdded"`
|
||||
BlackDeleted struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
}
|
||||
} `yaml:"blackDeleted"`
|
||||
}
|
||||
Demo struct {
|
||||
Port []int `yaml:"openImDemoPort"`
|
||||
@@ -288,6 +288,7 @@ type config struct {
|
||||
VerificationCodeTemplateCode string `yaml:"verificationCodeTemplateCode"`
|
||||
}
|
||||
SuperCode string `yaml:"superCode"`
|
||||
CodeTTL int `yaml:"codeTTL"`
|
||||
Mail struct {
|
||||
Title string `yaml:"title"`
|
||||
SenderMail string `yaml:"senderMail"`
|
||||
|
||||
@@ -44,6 +44,7 @@ const (
|
||||
GroupMsg = 201
|
||||
|
||||
//SysRelated
|
||||
NotificationBegin = 1000
|
||||
|
||||
FriendApplicationApprovedNotification = 1201 //add_friend_response
|
||||
FriendApplicationRejectedNotification = 1202 //add_friend_response
|
||||
@@ -66,6 +67,7 @@ const (
|
||||
MemberKickedNotification = 1508
|
||||
MemberInvitedNotification = 1509
|
||||
MemberEnterNotification = 1510
|
||||
NotificationEnd = 2000
|
||||
|
||||
//MsgFrom
|
||||
UserMsgType = 100
|
||||
@@ -148,6 +150,12 @@ const (
|
||||
Female = 2
|
||||
)
|
||||
|
||||
const (
|
||||
UnreliableNotification = 1
|
||||
ReliableNotificationNoMsg = 2
|
||||
ReliableNotificationMsg = 3
|
||||
)
|
||||
|
||||
const FriendAcceptTip = "You have successfully become friends, so start chatting"
|
||||
|
||||
func GroupIsBanChat(status int32) bool {
|
||||
|
||||
@@ -69,14 +69,22 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
NoError = 0
|
||||
FormattingError = 10001
|
||||
DatabaseError = 10002
|
||||
LogicalError = 10003
|
||||
ServerError = 10004
|
||||
HttpError = 10005
|
||||
IoError = 10006
|
||||
IntentionalError = 10007
|
||||
NoError = 0
|
||||
FormattingError = 10001
|
||||
HasRegistered = 10002
|
||||
NotRegistered = 10003
|
||||
PasswordErr = 10004
|
||||
GetIMTokenErr = 10005
|
||||
RepeatSendCode = 10006
|
||||
MailSendCodeErr = 10007
|
||||
SmsSendCodeErr = 10008
|
||||
CodeInvalidOrExpired = 10009
|
||||
RegisterFailed = 10010
|
||||
DatabaseError = 10002
|
||||
ServerError = 10004
|
||||
HttpError = 10005
|
||||
IoError = 10006
|
||||
IntentionalError = 10007
|
||||
)
|
||||
|
||||
func (e ErrInfo) Error() string {
|
||||
|
||||
@@ -2,6 +2,12 @@ package db
|
||||
|
||||
import "time"
|
||||
|
||||
type Register struct {
|
||||
Account string `gorm:"column:account;primary_key;type:char(255)" json:"account"`
|
||||
Password string `gorm:"column:password;type:varchar(255)" json:"password"`
|
||||
Ex string `gorm:"column:ex;size:1024" json:"ex"`
|
||||
}
|
||||
|
||||
//
|
||||
//message FriendInfo{
|
||||
//string OwnerUserID = 1;
|
||||
@@ -47,6 +53,10 @@ type FriendRequest struct {
|
||||
Ex string `gorm:"column:ex;size:1024"`
|
||||
}
|
||||
|
||||
func (FriendRequest) TableName() string {
|
||||
return "friend_requests"
|
||||
}
|
||||
|
||||
//message GroupInfo{
|
||||
// string GroupID = 1;
|
||||
// string GroupName = 2;
|
||||
@@ -69,7 +79,7 @@ type Group struct {
|
||||
GroupName string `gorm:"column:name;size:255" json:"groupName"`
|
||||
Notification string `gorm:"column:notification;size:255" json:"notification"`
|
||||
Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
|
||||
FaceUrl string `gorm:"column:face_url;size:255" json:"faceUrl"`
|
||||
FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"`
|
||||
Status int32 `gorm:"column:status"`
|
||||
@@ -93,7 +103,7 @@ type GroupMember struct {
|
||||
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||
Nickname string `gorm:"column:nickname;size:255"`
|
||||
FaceUrl string `gorm:"column:user_group_face_url;size:255"`
|
||||
FaceURL string `gorm:"column:user_group_face_url;size:255"`
|
||||
RoleLevel int32 `gorm:"column:role_level"`
|
||||
JoinTime time.Time `gorm:"column:join_time"`
|
||||
JoinSource int32 `gorm:"column:join_source"`
|
||||
@@ -179,7 +189,6 @@ type ChatLog struct {
|
||||
ContentType int32 `gorm:"column:content_type" json:"contentType"`
|
||||
Content string `gorm:"column:content;type:varchar(1000)" json:"content"`
|
||||
Status int32 `gorm:"column:status" json:"status"`
|
||||
Seq uint32 `gorm:"column:seq;index:index_seq;default:0" json:"seq"`
|
||||
SendTime time.Time `gorm:"column:send_time" json:"sendTime"`
|
||||
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
|
||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||
|
||||
+45
-37
@@ -36,7 +36,7 @@ func initMysqlDB() {
|
||||
}
|
||||
|
||||
//Check the database and table during initialization
|
||||
sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s ;", config.Config.Mysql.DBDatabaseName+"test1")
|
||||
sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s default charset utf8 COLLATE utf8_general_ci;", config.Config.Mysql.DBDatabaseName)
|
||||
err = db.Exec(sql).Error
|
||||
if err != nil {
|
||||
log.NewError("0", "Exec failed ", err.Error(), sql)
|
||||
@@ -59,44 +59,52 @@ func initMysqlDB() {
|
||||
&GroupMember{},
|
||||
&GroupRequest{},
|
||||
&User{},
|
||||
&Black{}, &ChatLog{})
|
||||
&Black{}, &ChatLog{}, &Register{})
|
||||
db.Set("gorm:table_options", "CHARSET=utf8")
|
||||
db.Set("gorm:table_options", "collation=utf8_unicode_ci")
|
||||
|
||||
//
|
||||
//if !db.HasTable(&Friend{}) {
|
||||
// log.NewInfo("CreateTable Friend")
|
||||
// db.CreateTable(&Friend{})
|
||||
//}
|
||||
//
|
||||
//if !db.HasTable(&FriendRequest{}) {
|
||||
// log.NewInfo("CreateTable FriendRequest")
|
||||
// db.CreateTable(&FriendRequest{})
|
||||
//}
|
||||
//
|
||||
//if !db.HasTable(&Group{}) {
|
||||
// log.NewInfo("CreateTable Group")
|
||||
// db.CreateTable(&Group{})
|
||||
//}
|
||||
//
|
||||
//if !db.HasTable(&GroupMember{}) {
|
||||
// log.NewInfo("CreateTable GroupMember")
|
||||
// db.CreateTable(&GroupMember{})
|
||||
//}
|
||||
//
|
||||
//if !db.HasTable(&GroupRequest{}) {
|
||||
// log.NewInfo("CreateTable GroupRequest")
|
||||
// db.CreateTable(&GroupRequest{})
|
||||
//}
|
||||
//
|
||||
//if !db.HasTable(&User{}) {
|
||||
// log.NewInfo("CreateTable User")
|
||||
// db.CreateTable(&User{})
|
||||
//}
|
||||
//
|
||||
//if !db.HasTable(&Black{}) {
|
||||
// log.NewInfo("CreateTable Black")
|
||||
// db.CreateTable(&Black{})
|
||||
//}
|
||||
if !db.HasTable(&Friend{}) {
|
||||
log.NewInfo("CreateTable Friend")
|
||||
db.CreateTable(&Friend{})
|
||||
}
|
||||
|
||||
if !db.HasTable(&FriendRequest{}) {
|
||||
log.NewInfo("CreateTable FriendRequest")
|
||||
db.CreateTable(&FriendRequest{})
|
||||
}
|
||||
|
||||
if !db.HasTable(&Group{}) {
|
||||
log.NewInfo("CreateTable Group")
|
||||
db.CreateTable(&Group{})
|
||||
}
|
||||
|
||||
if !db.HasTable(&GroupMember{}) {
|
||||
log.NewInfo("CreateTable GroupMember")
|
||||
db.CreateTable(&GroupMember{})
|
||||
}
|
||||
|
||||
if !db.HasTable(&GroupRequest{}) {
|
||||
log.NewInfo("CreateTable GroupRequest")
|
||||
db.CreateTable(&GroupRequest{})
|
||||
}
|
||||
|
||||
if !db.HasTable(&User{}) {
|
||||
log.NewInfo("CreateTable User")
|
||||
db.CreateTable(&User{})
|
||||
}
|
||||
|
||||
if !db.HasTable(&Black{}) {
|
||||
log.NewInfo("CreateTable Black")
|
||||
db.CreateTable(&Black{})
|
||||
}
|
||||
if !db.HasTable(&ChatLog{}) {
|
||||
log.NewInfo("CreateTable Black")
|
||||
db.CreateTable(&ChatLog{})
|
||||
}
|
||||
if !db.HasTable(&Register{}) {
|
||||
log.NewInfo("CreateTable Black")
|
||||
db.CreateTable(&Register{})
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -5,60 +5,25 @@ import (
|
||||
_ "github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type GetRegisterParams struct {
|
||||
Account string `json:"account"`
|
||||
}
|
||||
type Register struct {
|
||||
Account string `gorm:"column:account"`
|
||||
Password string `gorm:"column:password"`
|
||||
}
|
||||
|
||||
func GetRegister(params *GetRegisterParams) (Register, error, int64) {
|
||||
var r Register
|
||||
func GetRegister(account string) (*db.Register, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return r, err, 0
|
||||
return nil, err
|
||||
}
|
||||
result := dbConn.
|
||||
Where(&Register{Account: params.Account}).
|
||||
Find(&r)
|
||||
return r, result.Error, result.RowsAffected
|
||||
var r db.Register
|
||||
return &r, dbConn.Table("registers").Where("account = ?",
|
||||
account).Take(&r).Error
|
||||
}
|
||||
|
||||
type SetPasswordParams struct {
|
||||
Account string `json:"account"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
func SetPassword(params *SetPasswordParams) (Register, error) {
|
||||
r := Register{
|
||||
Account: params.Account,
|
||||
Password: params.Password,
|
||||
func SetPassword(account, password, ex string) error {
|
||||
r := db.Register{
|
||||
Account: account,
|
||||
Password: password,
|
||||
Ex: ex,
|
||||
}
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return r, err
|
||||
return err
|
||||
}
|
||||
return dbConn.Table("registers").Create(&r).Error
|
||||
|
||||
result := dbConn.Create(&r)
|
||||
|
||||
return r, result.Error
|
||||
}
|
||||
|
||||
func Login(params *Register) int64 {
|
||||
var r Register
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return 3
|
||||
}
|
||||
result := dbConn.
|
||||
Where(&Register{Account: params.Account}).
|
||||
Find(&r)
|
||||
if result.Error != nil && result.RowsAffected == 0 {
|
||||
return 1
|
||||
}
|
||||
if r.Password != params.Password {
|
||||
return 2
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -71,11 +71,33 @@ func UpdateFriendApplication(friendRequest *db.FriendRequest) error {
|
||||
friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest).Error
|
||||
}
|
||||
|
||||
func InsertFriendApplication(friendRequest *db.FriendRequest) error {
|
||||
func InsertFriendApplication(friendRequest *db.FriendRequest, args map[string]interface{}) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = dbConn.Table("friend_requests").Create(friendRequest).Error; err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
//t := dbConn.Debug().Table("friend_requests").Where("from_user_id = ? and to_user_id = ?", friendRequest.FromUserID, friendRequest.ToUserID).Select("*").Updates(*friendRequest)
|
||||
//if t.RowsAffected == 0 {
|
||||
// return utils.Wrap(errors.New("RowsAffected == 0"), "no update")
|
||||
//}
|
||||
//return utils.Wrap(t.Error, "")
|
||||
|
||||
friendRequest.CreateTime = time.Now()
|
||||
args["create_time"] = friendRequest.CreateTime
|
||||
u := dbConn.Model(friendRequest).Updates(args)
|
||||
//u := dbConn.Table("friend_requests").Where("from_user_id=? and to_user_id=?",
|
||||
// friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest)
|
||||
//u := dbConn.Table("friend_requests").Where("from_user_id=? and to_user_id=?",
|
||||
// friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest)
|
||||
if u.RowsAffected != 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if friendRequest.CreateTime.Unix() < 0 {
|
||||
friendRequest.CreateTime = time.Now()
|
||||
}
|
||||
|
||||
@@ -31,11 +31,20 @@ func UpdateGroupRequest(groupRequest db.GroupRequest) error {
|
||||
}
|
||||
|
||||
func InsertIntoGroupRequest(toInsertInfo db.GroupRequest) error {
|
||||
DelGroupRequestByGroupIDAndUserID(toInsertInfo.GroupID, toInsertInfo.UserID)
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if toInsertInfo.HandledTime.Unix() < 0 {
|
||||
toInsertInfo.HandledTime = utils.UnixSecondToTime(0)
|
||||
}
|
||||
u := dbConn.Table("group_requests").Where("group_id=? and user_id=?", toInsertInfo.GroupID, toInsertInfo.UserID).Update(&toInsertInfo)
|
||||
if u.RowsAffected != 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
toInsertInfo.ReqTime = time.Now()
|
||||
if toInsertInfo.HandledTime.Unix() < 0 {
|
||||
toInsertInfo.HandledTime = utils.UnixSecondToTime(0)
|
||||
@@ -108,6 +117,18 @@ func GetGroupApplicationList(userID string) ([]db.GroupRequest, error) {
|
||||
return groupRequestList, nil
|
||||
}
|
||||
|
||||
func GetUserReqGroupByUserID(userID string) ([]db.GroupRequest, error) {
|
||||
var groupRequestList []db.GroupRequest
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
err = dbConn.Table("group_requests").Where("user_id=?", userID).Find(&groupRequestList).Error
|
||||
return groupRequestList, err
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.CommonResp, error) {
|
||||
//
|
||||
|
||||
@@ -10,7 +10,10 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
@@ -27,7 +30,19 @@ func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error {
|
||||
case constant.SingleChatType:
|
||||
chatLog.RecvID = msg.MsgData.RecvID
|
||||
}
|
||||
chatLog.Content = string(msg.MsgData.Content)
|
||||
if msg.MsgData.ContentType >= constant.NotificationBegin && msg.MsgData.ContentType <= constant.NotificationEnd {
|
||||
var tips server_api_params.TipsComm
|
||||
_ = proto.Unmarshal(msg.MsgData.Content, &tips)
|
||||
marshaler := jsonpb.Marshaler{
|
||||
OrigName: true,
|
||||
EnumsAsInts: false,
|
||||
EmitDefaults: false,
|
||||
}
|
||||
chatLog.Content, _ = marshaler.MarshalToString(&tips)
|
||||
|
||||
} else {
|
||||
chatLog.Content = string(msg.MsgData.Content)
|
||||
}
|
||||
chatLog.CreateTime = utils.UnixMillSecondToTime(msg.MsgData.CreateTime)
|
||||
chatLog.SendTime = utils.UnixMillSecondToTime(msg.MsgData.SendTime)
|
||||
return dbConn.Table("chat_logs").Create(chatLog).Error
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
registerAccountTempCode = "REGISTER_ACCOUNT_TEMP_CODE"
|
||||
userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq
|
||||
appleDeviceToken = "DEVICE_TOKEN"
|
||||
userMinSeq = "REDIS_USER_MIN_SEQ:"
|
||||
@@ -33,6 +34,19 @@ func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (inte
|
||||
|
||||
return con.Do(cmd, params...)
|
||||
}
|
||||
func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) {
|
||||
key := registerAccountTempCode + account
|
||||
return redis.Bool(d.Exec("EXISTS", key))
|
||||
}
|
||||
func (d *DataBases) SetAccountCode(account string, code, ttl int) (err error) {
|
||||
key := registerAccountTempCode + account
|
||||
_, err = d.Exec("Set", key, code, ttl)
|
||||
return err
|
||||
}
|
||||
func (d *DataBases) GetAccountCode(account string) (string, error) {
|
||||
key := userIncrSeq + account
|
||||
return redis.String(d.Exec("GET", key))
|
||||
}
|
||||
|
||||
//Perform seq auto-increment operation of user messages
|
||||
func (d *DataBases) IncrUserSeq(uid string) (uint64, error) {
|
||||
|
||||
@@ -29,6 +29,9 @@ func FriendDBCopyOpenIM(dst *open_im_sdk.FriendInfo, src *db.Friend) error {
|
||||
}
|
||||
utils.CopyStructFields(dst.FriendUser, user)
|
||||
dst.CreateTime = uint32(src.CreateTime.Unix())
|
||||
if dst.FriendUser == nil {
|
||||
dst.FriendUser = &open_im_sdk.UserInfo{}
|
||||
}
|
||||
dst.FriendUser.CreateTime = uint32(user.CreateTime.Unix())
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user