diff --git a/internal/common/check/black.go b/internal/common/check/black.go index 3e15bec0b..429aa80f6 100644 --- a/internal/common/check/black.go +++ b/internal/common/check/black.go @@ -17,5 +17,5 @@ func NewBlackChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *BlackChecker { // possibleBlackUserID是否被userID拉黑,也就是是否在userID的黑名单中 func (b *BlackChecker) IsBlocked(ctx context.Context, possibleBlackUserID, userID string) (bool, error) { - + return false, nil } diff --git a/internal/common/check/conversation.go b/internal/common/check/conversation.go index c56330c5b..a5413d1e2 100644 --- a/internal/common/check/conversation.go +++ b/internal/common/check/conversation.go @@ -31,5 +31,5 @@ func (c *ConversationChecker) getConn() (*grpc.ClientConn, error) { } func (c *ConversationChecker) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) { - + panic("implement me") } diff --git a/internal/common/check/friend.go b/internal/common/check/friend.go index 6c4a50a48..994a5afa7 100644 --- a/internal/common/check/friend.go +++ b/internal/common/check/friend.go @@ -37,5 +37,5 @@ func (f *FriendChecker) getConn() (*grpc.ClientConn, error) { // possibleFriendUserID是否在userID的好友中 func (f *FriendChecker) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) { - + return false, nil } diff --git a/internal/common/check/msg.go b/internal/common/check/msg.go index bc3adf16f..010ee1606 100644 --- a/internal/common/check/msg.go +++ b/internal/common/check/msg.go @@ -28,39 +28,3 @@ func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendM resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req) return resp, err } - -func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) { - cc, err := m.getConn() - if err != nil { - return nil, err - } - resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req) - return resp, err -} - -func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) { - cc, err := m.getConn() - if err != nil { - return nil, err - } - resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req) - return resp, err -} - -func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) { - cc, err := m.getConn() - if err != nil { - return nil, err - } - resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req) - return resp, err -} - -func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) { - cc, err := m.getConn() - if err != nil { - return nil, err - } - resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req) - return resp, err -} diff --git a/internal/common/check/user.go b/internal/common/check/user.go index 5e5b38ee7..7e6f89eb5 100644 --- a/internal/common/check/user.go +++ b/internal/common/check/user.go @@ -104,5 +104,5 @@ func (u *UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, } func (u *UserCheck) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) { - + return 0, nil } diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go index 0491d36c7..94e07f78e 100644 --- a/pkg/common/db/cache/conversation.go +++ b/pkg/common/db/cache/conversation.go @@ -9,7 +9,7 @@ import ( "encoding/json" "github.com/dtm-labs/rockscache" "github.com/go-redis/redis/v8" - "golang.org/x/tools/go/ssa/testdata/src/strconv" + "strconv" "time" ) @@ -20,6 +20,7 @@ const ( superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:" conversationExpireTime = time.Second * 60 * 60 * 12 ) + type FuncDB func() (string, error) // arg fn will exec when no data in cache @@ -28,13 +29,13 @@ type ConversationCache interface { GetUserConversationIDs(ctx context.Context, userID string, fn FuncDB) ([]string, error) // del user's conversationIDs from cache, call when a user add or reduce a conversation DelUserConversationIDs(ctx context.Context, userID string) error - DelUsersConversationIDs(ctx context.Context,userIDList []string)error + DelUsersConversationIDs(ctx context.Context, userIDList []string) error // get one conversation from cache GetConversation(ctx context.Context, ownerUserID, conversationID string, fn FuncDB) (*relationTb.ConversationModel, error) // get one conversation from cache - GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB)([]*relationTb.ConversationModel, error) + GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB) ([]*relationTb.ConversationModel, error) // get one user's all conversations from cache - GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB ) ([]*relationTb.ConversationModel, error) + GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB) ([]*relationTb.ConversationModel, error) // del one conversation from cache, call when one user's conversation Info changed DelConversation(ctx context.Context, ownerUserID, conversationID string) error DelUserConversations(ctx context.Context, ownerUserID string, conversationIDList []string) error @@ -55,38 +56,14 @@ type ConversationRedis struct { rcClient *rockscache.Client } -func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, userID string, fn func(ctx context.Context, userID string) ([]string, error)) ([]string, error) { - panic("implement me") -} - func (c *ConversationRedis) DelUsersConversationIDs(ctx context.Context, userIDList []string) error { panic("implement me") } -func (c *ConversationRedis) GetConversation(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error)) (*relationTb.ConversationModel, error) { - panic("implement me") -} - -func (c *ConversationRedis) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB) ([]*relationTb.ConversationModel, error) { - panic("implement me") -} - -func (c *ConversationRedis) GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB) ([]*relationTb.ConversationModel, error) { - panic("implement me") -} - func (c *ConversationRedis) DelUsersConversation(ctx context.Context, ownerUserIDList []string, conversationID string) error { panic("implement me") } -func (c *ConversationRedis) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID string, conversationID string) (opt int, err error)) (opt int, err error) { - panic("implement me") -} - -func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string, fn func(ctx context.Context, groupID string) (userIDs []string, err error)) (userIDs []string, err error) { - panic("implement me") -} - func NewConversationRedis(rcClient *rockscache.Client) *ConversationRedis { return &ConversationRedis{rcClient: rcClient} } @@ -158,7 +135,11 @@ func (c *ConversationRedis) GetUserConversationIDs1(ctx context.Context, ownerUs // return nil, utils.Wrap(err, "") //} //return conversationIDs, nil - return GetCache1[[]string](c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, fn) + //return GetCache1[[]string](c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, fn) + + return GetCache(ctx, c.rcClient, c.getConversationIDsKey(ownerUserID), conversationExpireTime, func(ctx context.Context) ([]string, error) { + panic("") + }) } //func GetCache1[T any](rcClient *rockscache.Client, key string, expire time.Duration, fn func() (any, error)) (T, error) {