mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 11:35:59 +08:00
notification
This commit is contained in:
@@ -10,7 +10,7 @@ const (
|
||||
Application = 0
|
||||
AgreeApplication = 1
|
||||
|
||||
//feiend related
|
||||
//friend related
|
||||
BlackListFlag = 1
|
||||
ApplicationFriendFlag = 0
|
||||
FriendFlag = 1
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// reqId add userId
|
||||
func ReplaceIntoFriendReq(reqId, userId string, flag int32, reqMessage string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
@@ -44,6 +45,7 @@ func FindSelfApplyFromFriendReq(userId string) ([]FriendRequest, error) {
|
||||
return usersInfo, nil
|
||||
}
|
||||
|
||||
//reqId apply to add userId already
|
||||
func FindFriendApplyFromFriendReqByUid(reqId, userId string) (*FriendRequest, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
@@ -57,6 +59,7 @@ func FindFriendApplyFromFriendReqByUid(reqId, userId string) (*FriendRequest, er
|
||||
return &friendRequest, nil
|
||||
}
|
||||
|
||||
//userId process reqId
|
||||
func UpdateFriendRelationshipToFriendReq(reqId, userId string, flag int32) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
|
||||
@@ -212,6 +212,19 @@ func GetGroupOwnerByGroupId(groupId string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetGroupOwnerInfoByGroupId(groupId string) (*GroupMember, error) {
|
||||
omList, err := GetOwnerManagerByGroupId(groupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range omList {
|
||||
if v.AdministratorLevel == 1 {
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func InsertGroupMember(groupId, userId, nickName, userFaceUrl string, role int32) error {
|
||||
return InsertIntoGroupMember(groupId, userId, nickName, userFaceUrl, role)
|
||||
}
|
||||
|
||||
@@ -164,12 +164,12 @@ func GetGroupApplicationList(uid string) (*group.GetGroupApplicationListResp, er
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func TransferGroupOwner(pb *group.TransferGroupOwnerReq) (*group.TransferGroupOwnerResp, error) {
|
||||
oldOwner, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OldOwner)
|
||||
func TransferGroupOwner(pb *group.TransferGroupOwnerReq) (*group.CommonResp, error) {
|
||||
oldOwner, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OldOwnerUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newOwner, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.NewOwner)
|
||||
newOwner, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.NewOwnerUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -178,19 +178,19 @@ func TransferGroupOwner(pb *group.TransferGroupOwnerReq) (*group.TransferGroupOw
|
||||
return nil, errors.New("the self")
|
||||
}
|
||||
|
||||
if err = UpdateTheUserAdministratorLevel(pb.GroupID, pb.OldOwner, 0); err != nil {
|
||||
if err = UpdateTheUserAdministratorLevel(pb.GroupID, pb.OldOwnerUserID, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = UpdateTheUserAdministratorLevel(pb.GroupID, pb.NewOwner, 1); err != nil {
|
||||
UpdateTheUserAdministratorLevel(pb.GroupID, pb.OldOwner, 1)
|
||||
if err = UpdateTheUserAdministratorLevel(pb.GroupID, pb.NewOwnerUserID, 1); err != nil {
|
||||
UpdateTheUserAdministratorLevel(pb.GroupID, pb.OldOwnerUserID, 1)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &group.TransferGroupOwnerResp{}, nil
|
||||
return &group.CommonResp{}, nil
|
||||
}
|
||||
|
||||
func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.GroupApplicationResponseResp, error) {
|
||||
func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.CommonResp, error) {
|
||||
|
||||
ownerUser, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OwnerID)
|
||||
if err != nil {
|
||||
|
||||
@@ -41,7 +41,7 @@ type Group struct {
|
||||
Notification string `gorm:"column:notification"`
|
||||
FaceUrl string `gorm:"column:face_url"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
Ex string `gorm:"column:ex"`
|
||||
Ext string `gorm:"column:ex"`
|
||||
}
|
||||
|
||||
type GroupMember struct {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
"time"
|
||||
)
|
||||
@@ -80,6 +81,43 @@ func GetClaimFromToken(tokensString string) (*Claims, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func IsAppManagerAccess(token string, OpUserID string) bool {
|
||||
claims, err := ParseToken(token)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) && claims.UID == OpUserID {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsMangerUserID(OpUserID string) bool {
|
||||
if utils.IsContain(OpUserID, config.Config.Manager.AppManagerUid) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func CheckAccess(OpUserID string, OwnerUserID string) bool {
|
||||
if utils.IsContain(OpUserID, config.Config.Manager.AppManagerUid) {
|
||||
return true
|
||||
}
|
||||
if OpUserID == OwnerUserID {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetUserIDFromToken(token string) (bool, string) {
|
||||
claims, err := ParseToken(token)
|
||||
if err != nil {
|
||||
return false, ""
|
||||
}
|
||||
return true, claims.UID
|
||||
}
|
||||
|
||||
func ParseToken(tokensString string) (claims *Claims, err error) {
|
||||
|
||||
claims, err = GetClaimFromToken(tokensString)
|
||||
|
||||
Reference in New Issue
Block a user