notification

This commit is contained in:
wenxu12345
2021-12-21 21:40:50 +08:00
parent 2876e77a08
commit 75e1e2e678
25 changed files with 2237 additions and 955 deletions
+55 -1
View File
@@ -1,6 +1,7 @@
package config
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -158,6 +159,59 @@ type config struct {
CallbackUrl string `yaml:"callbackUrl"`
CallBackTimeOut int `yaml:"callbackTimeOut"`
}
IOSPush struct {
PushSound string `yaml:"pushSound"`
BadgeCount bool `yaml:"badgeCount"`
}
Notification struct {
GroupCreated struct {
Conversation struct {
ConversationChanged bool `yaml:"conversationChanged"`
UnreadCount bool `yaml:"unreadCount"`
}
OfflinePush struct {
PushSwitch bool `yaml:"switch"`
Title string `yaml:"title"`
Desc string `yaml:"desc"`
Ext string `yaml:"ext"`
}
DefaultTips struct {
Tips string `yaml:"tips"`
}
}
GroupInfoChanged struct {
Conversation struct {
ConversationChanged bool `yaml:"conversationChanged"`
UnreadCount bool `yaml:"unreadCount"`
}
OfflinePush struct {
PushSwitch bool `yaml:"switch"`
Title string `yaml:"title"`
Desc string `yaml:"desc"`
Ext string `yaml:"ext"`
}
DefaultTips struct {
Tips string `yaml:"tips"`
}
}
ApplyJoinGroup struct {
Conversation struct {
ConversationChanged bool `yaml:"conversationChanged"`
UnreadCount bool `yaml:"unreadCount"`
}
OfflinePush struct {
PushSwitch bool `yaml:"switch"`
Title string `yaml:"title"`
Desc string `yaml:"desc"`
Ext string `yaml:"ext"`
}
DefaultTips struct {
Tips string `yaml:"tips"`
}
}
}
Demo struct {
Port []int `yaml:"openImDemoPort"`
AliSMSVerify struct {
@@ -200,5 +254,5 @@ func init() {
if err = yaml.Unmarshal(bytes, &Config); err != nil {
panic(err.Error())
}
fmt.Println("load config: ", Config)
}
+2 -1
View File
@@ -54,13 +54,14 @@ const (
TransferGroupOwnerTip = 501
CreateGroupTip = 502
GroupApplicationResponseTip = 503
JoinGroupTip = 504
ApplyJoinGroupTip = 504
QuitGroupTip = 505
SetGroupInfoTip = 506
AcceptGroupApplicationTip = 507
RefuseGroupApplicationTip = 508
KickGroupMemberTip = 509
InviteUserToGroupTip = 510
ChangeGroupInfoTip = 511
//MsgFrom
UserMsgType = 100
@@ -12,10 +12,10 @@ func InsertToFriend(ownerId, friendId string, flag int32) error {
return err
}
toInsertFollow := Friend{
OwnerId: ownerId,
FriendId: friendId,
FriendFlag: flag,
CreateTime: time.Now(),
OwnerUserID: ownerId,
FriendUserID: friendId,
FriendFlag: flag,
CreateTime: time.Now(),
}
err = dbConn.Table("friend").Create(toInsertFollow).Error
if err != nil {
@@ -10,7 +10,7 @@ func InsertIntoGroupMember(groupId, uid, nickName, userGroupFaceUrl string, admi
if err != nil {
return err
}
toInsertInfo := GroupMember{GroupId: groupId, Uid: uid, NickName: nickName, AdministratorLevel: administratorLevel, JoinTime: time.Now(), UserGroupFaceUrl: userGroupFaceUrl}
toInsertInfo := GroupMember{GroupID: groupId, UserID: uid, NickName: nickName, AdministratorLevel: administratorLevel, JoinTime: time.Now(), FaceUrl: userGroupFaceUrl}
err = dbConn.Table("group_member").Create(toInsertInfo).Error
if err != nil {
return err
@@ -206,7 +206,7 @@ func GetGroupOwnerByGroupId(groupId string) string {
}
for _, v := range omList {
if v.AdministratorLevel == 1 {
return v.Uid
return v.UserID
}
}
return ""
@@ -17,7 +17,7 @@ func InsertIntoGroup(groupId, name, introduction, notification, faceUrl, ex stri
if name == "" {
name = "groupChat"
}
toInsertInfo := Group{GroupId: groupId, Name: name, Introduction: introduction, Notification: notification, FaceUrl: faceUrl, CreateTime: time.Now(), Ex: ex}
toInsertInfo := Group{GroupID: groupId, GroupName: name, Introduction: introduction, Notification: notification, FaceUrl: faceUrl, CreateTime: time.Now(), Ex: ex}
err = dbConn.Table("group").Create(toInsertInfo).Error
if err != nil {
return err
@@ -174,7 +174,7 @@ func TransferGroupOwner(pb *group.TransferGroupOwnerReq) (*group.TransferGroupOw
return nil, err
}
if oldOwner.Uid == newOwner.Uid {
if oldOwner.UserID == newOwner.UserID {
return nil, errors.New("the self")
}
@@ -248,55 +248,5 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
}
}
//if err != nil {
// err = dbConn.Raw("select * from `group_request` where handled_user = ? and group_id = ? and to_user_id = ? and from_user_id = ?", "", pb.GroupID, "0", pb.UID).Scan(&groupRequest).Error
// if err != nil {
// return nil, err
// }
// if pb.Flag == 1 {
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ? and from_user_id = ?",
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, "0", pb.UID).Error
// if err != nil {
// return nil, err
// }
//
// // add to group member
// err = InsertIntoGroupMember(pb.GroupID, pb.UID, groupRequest.FromUserNickname, groupRequest.FromUserFaceUrl, 0)
// if err != nil {
// return nil, err
// }
// } else if pb.Flag == -1 {
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ? and from_user_id = ?",
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, "0", pb.UID).Error
// if err != nil {
// return nil, err
// }
// } else {
// return nil, errors.New("flag error")
// }
//} else {
// if pb.Flag == 1 {
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ?",
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, pb.UID).Error
// if err != nil {
// return nil, err
// }
//
// // add to group member
// err = InsertIntoGroupMember(pb.GroupID, pb.UID, groupRequest.ToUserNickname, groupRequest.ToUserFaceUrl, 0)
// if err != nil {
// return nil, err
// }
// } else if pb.Flag == -1 {
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ?",
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, pb.UID).Error
// if err != nil {
// return nil, err
// }
// } else {
// return nil, errors.New("flag error")
// }
//}
return &group.GroupApplicationResponseResp{}, nil
}
@@ -3,9 +3,9 @@ package im_mysql_model
import "time"
type User struct {
UID string `gorm:"column:uid;primaryKey;"`
Name string `gorm:"column:name"`
Icon string `gorm:"column:icon"`
UserID string `gorm:"column:uid;primaryKey;"`
Nickname string `gorm:"column:name"`
FaceUrl string `gorm:"column:icon"`
Gender int32 `gorm:"column:gender"`
Mobile string `gorm:"column:mobile"`
Birth string `gorm:"column:birth"`
@@ -15,28 +15,28 @@ type User struct {
}
type Friend struct {
OwnerId string `gorm:"column:owner_id"`
FriendId string `gorm:"column:friend_id"`
Comment string `gorm:"column:comment"`
FriendFlag int32 `gorm:"column:friend_flag"`
CreateTime time.Time `gorm:"column:create_time"`
OwnerUserID string `gorm:"column:owner_id"`
FriendUserID string `gorm:"column:friend_id"`
Remark string `gorm:"column:comment"`
FriendFlag int32 `gorm:"column:friend_flag"`
CreateTime time.Time `gorm:"column:create_time"`
}
type FriendRequest struct {
ReqId string `gorm:"column:req_id"`
Uid string `gorm:"column:user_id"`
ReqID string `gorm:"column:req_id"`
UserID string `gorm:"column:user_id"`
Flag int32 `gorm:"column:flag"`
ReqMessage string `gorm:"column:req_message"`
CreateTime time.Time `gorm:"column:create_time"`
}
type BlackList struct {
OwnerId string `gorm:"column:owner_id"`
BlockId string `gorm:"column:block_id"`
CreateTime time.Time `gorm:"column:create_time"`
OwnerUserID string `gorm:"column:owner_id"`
BlockUserID string `gorm:"column:block_id"`
CreateTime time.Time `gorm:"column:create_time"`
}
type Group struct {
GroupId string `gorm:"column:group_id"`
Name string `gorm:"column:name"`
GroupID string `gorm:"column:group_id"`
GroupName string `gorm:"column:name"`
Introduction string `gorm:"column:introduction"`
Notification string `gorm:"column:notification"`
FaceUrl string `gorm:"column:face_url"`
@@ -45,12 +45,12 @@ type Group struct {
}
type GroupMember struct {
GroupId string `gorm:"column:group_id"`
Uid string `gorm:"column:uid"`
GroupID string `gorm:"column:group_id"`
UserID string `gorm:"column:uid"`
NickName string `gorm:"column:nickname"`
AdministratorLevel int32 `gorm:"column:administrator_level"`
JoinTime time.Time `gorm:"column:join_time"`
UserGroupFaceUrl string `gorm:"user_group_face_url"`
FaceUrl string `gorm:"user_group_face_url"`
}
type GroupRequest struct {
@@ -10,7 +10,7 @@ func InsertInToUserBlackList(ownerID, blockID string) error {
if err != nil {
return err
}
toInsertInfo := BlackList{OwnerId: ownerID, BlockId: blockID, CreateTime: time.Now()}
toInsertInfo := BlackList{OwnerUserID: ownerID, BlockUserID: blockID, CreateTime: time.Now()}
err = dbConn.Table("user_black_list").Create(toInsertInfo).Error
return err
}
@@ -30,9 +30,9 @@ func UserRegister(pb *pbAuth.UserRegisterReq) error {
return err
}
addUser := User{
UID: pb.UID,
Name: pb.Name,
Icon: pb.Icon,
UserID: pb.UID,
Nickname: pb.Name,
FaceUrl: pb.Icon,
Gender: pb.Gender,
Mobile: pb.Mobile,
Birth: pb.Birth,
@@ -17,20 +17,3 @@ type Receive struct {
MsgId string
CreateTime *time.Time
}
//func InsertMessageToReceive(seq int64, userid, msgid string) error {
// conn := db.NewDbConnection()
// receive := Receive{
// UID: userid,
// Seq: seq,
// MsgId: msgid,
// }
// err := conn.Table("receive").Create(&receive).Error
// return err
//}
//func GetBiggestSeqFromReceive(userid string) (seq int64, err error) {
// //得到数据库的连接(并非真连接,调用时才连接,由gorm自动维护数据库连接池)
// conn := db.NewDbConnection()
// err = conn.Raw("select max(seq) from receive where user_id = ?", userid).Row().Scan(&seq)
// return seq, err
//}