mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-04 19:32:17 +08:00 
			
		
		
		
	GetOwnerConversation
This commit is contained in:
		
							parent
							
								
									e17f0c95aa
								
							
						
					
					
						commit
						ec7bebfb86
					
				
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@ -12,7 +12,7 @@ require (
 | 
				
			|||||||
	github.com/gorilla/websocket v1.5.1
 | 
						github.com/gorilla/websocket v1.5.1
 | 
				
			||||||
	github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
 | 
						github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
 | 
				
			||||||
	github.com/mitchellh/mapstructure v1.5.0
 | 
						github.com/mitchellh/mapstructure v1.5.0
 | 
				
			||||||
	github.com/openimsdk/protocol v0.0.69-alpha.27
 | 
						github.com/openimsdk/protocol v0.0.69-alpha.30
 | 
				
			||||||
	github.com/openimsdk/tools v0.0.49-alpha.45
 | 
						github.com/openimsdk/tools v0.0.49-alpha.45
 | 
				
			||||||
	github.com/pkg/errors v0.9.1 // indirect
 | 
						github.com/pkg/errors v0.9.1 // indirect
 | 
				
			||||||
	github.com/prometheus/client_golang v1.18.0
 | 
						github.com/prometheus/client_golang v1.18.0
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.sum
									
									
									
									
									
								
							@ -262,8 +262,8 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
 | 
				
			|||||||
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
 | 
					github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
 | 
				
			||||||
github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y=
 | 
					github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y=
 | 
				
			||||||
github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
 | 
					github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
 | 
				
			||||||
github.com/openimsdk/protocol v0.0.69-alpha.27 h1:0Ctpu9VBXVCkKno6vVNBgUTyo9W9bG7SZuAhQr/4H8Y=
 | 
					github.com/openimsdk/protocol v0.0.69-alpha.30 h1:OXzCIpDpIY/GI6h1SDYWN51OS9Xv/BcHaOwq8whPKqI=
 | 
				
			||||||
github.com/openimsdk/protocol v0.0.69-alpha.27/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
 | 
					github.com/openimsdk/protocol v0.0.69-alpha.30/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
 | 
				
			||||||
github.com/openimsdk/tools v0.0.49-alpha.45 h1:XIzCoef4myybOiIlGuRY9FTtGBisZFC4Uy4PhG0ZWQ0=
 | 
					github.com/openimsdk/tools v0.0.49-alpha.45 h1:XIzCoef4myybOiIlGuRY9FTtGBisZFC4Uy4PhG0ZWQ0=
 | 
				
			||||||
github.com/openimsdk/tools v0.0.49-alpha.45/go.mod h1:HtSRjPTL8PsuZ+PhR5noqzrYBF0sdwW3/O/sWVucWg8=
 | 
					github.com/openimsdk/tools v0.0.49-alpha.45/go.mod h1:HtSRjPTL8PsuZ+PhR5noqzrYBF0sdwW3/O/sWVucWg8=
 | 
				
			||||||
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
 | 
					github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
 | 
				
			||||||
 | 
				
			|||||||
@ -58,3 +58,7 @@ func (o *ConversationApi) GetFullOwnerConversationIDs(c *gin.Context) {
 | 
				
			|||||||
func (o *ConversationApi) GetIncrementalConversation(c *gin.Context) {
 | 
					func (o *ConversationApi) GetIncrementalConversation(c *gin.Context) {
 | 
				
			||||||
	a2r.Call(conversation.ConversationClient.GetIncrementalConversation, o.Client, c)
 | 
						a2r.Call(conversation.ConversationClient.GetIncrementalConversation, o.Client, c)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (o *ConversationApi) GetOwnerConversation(c *gin.Context) {
 | 
				
			||||||
 | 
						a2r.Call(conversation.ConversationClient.GetOwnerConversation, o.Client, c)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -194,6 +194,7 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
 | 
				
			|||||||
		conversationGroup.POST("/get_conversation_offline_push_user_ids", c.GetConversationOfflinePushUserIDs)
 | 
							conversationGroup.POST("/get_conversation_offline_push_user_ids", c.GetConversationOfflinePushUserIDs)
 | 
				
			||||||
		conversationGroup.POST("/get_full_conversation_ids", c.GetFullOwnerConversationIDs)
 | 
							conversationGroup.POST("/get_full_conversation_ids", c.GetFullOwnerConversationIDs)
 | 
				
			||||||
		conversationGroup.POST("/get_incremental_conversation", c.GetIncrementalConversation)
 | 
							conversationGroup.POST("/get_incremental_conversation", c.GetIncrementalConversation)
 | 
				
			||||||
 | 
							conversationGroup.POST("/get_owner_conversation", c.GetOwnerConversation)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	statisticsGroup := r.Group("/statistics")
 | 
						statisticsGroup := r.Group("/statistics")
 | 
				
			||||||
 | 
				
			|||||||
@ -591,3 +591,14 @@ func (c *conversationServer) UpdateConversation(ctx context.Context, req *pbconv
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	return &pbconversation.UpdateConversationResp{}, nil
 | 
						return &pbconversation.UpdateConversationResp{}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *conversationServer) GetOwnerConversation(ctx context.Context, req *pbconversation.GetOwnerConversationReq) (*pbconversation.GetOwnerConversationResp, error) {
 | 
				
			||||||
 | 
						total, conversations, err := c.conversationDatabase.GetOwnerConversation(ctx, req.UserID, req.Pagination)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return &pbconversation.GetOwnerConversationResp{
 | 
				
			||||||
 | 
							Total:         total,
 | 
				
			||||||
 | 
							Conversations: convert.ConversationsDB2Pb(conversations),
 | 
				
			||||||
 | 
						}, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ type ConversationDatabase interface {
 | 
				
			|||||||
	// FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
 | 
						// FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
 | 
				
			||||||
	FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*relationtb.VersionLog, error)
 | 
						FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*relationtb.VersionLog, error)
 | 
				
			||||||
	FindMaxConversationUserVersionCache(ctx context.Context, userID string) (*relationtb.VersionLog, error)
 | 
						FindMaxConversationUserVersionCache(ctx context.Context, userID string) (*relationtb.VersionLog, error)
 | 
				
			||||||
 | 
						GetOwnerConversation(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (int64, []*relationtb.Conversation, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewConversationDatabase(conversation database.Conversation, cache cache.ConversationCache, tx tx.Tx) ConversationDatabase {
 | 
					func NewConversationDatabase(conversation database.Conversation, cache cache.ConversationCache, tx tx.Tx) ConversationDatabase {
 | 
				
			||||||
@ -335,3 +336,20 @@ func (c *conversationDatabase) FindConversationUserVersion(ctx context.Context,
 | 
				
			|||||||
func (c *conversationDatabase) FindMaxConversationUserVersionCache(ctx context.Context, userID string) (*relationtb.VersionLog, error) {
 | 
					func (c *conversationDatabase) FindMaxConversationUserVersionCache(ctx context.Context, userID string) (*relationtb.VersionLog, error) {
 | 
				
			||||||
	return c.cache.FindMaxConversationUserVersion(ctx, userID)
 | 
						return c.cache.FindMaxConversationUserVersion(ctx, userID)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *conversationDatabase) GetOwnerConversation(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (int64, []*relationtb.Conversation, error) {
 | 
				
			||||||
 | 
						conversationIDs, err := c.cache.GetUserConversationIDs(ctx, ownerUserID)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return 0, nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						findConversationIDs := datautil.Paginate(conversationIDs, int(pagination.GetPageNumber()), int(pagination.GetShowNumber()))
 | 
				
			||||||
 | 
						conversations := make([]*relationtb.Conversation, 0, len(findConversationIDs))
 | 
				
			||||||
 | 
						for _, conversationID := range findConversationIDs {
 | 
				
			||||||
 | 
							conversation, err := c.cache.GetConversation(ctx, ownerUserID, conversationID)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return 0, nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							conversations = append(conversations, conversation)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return int64(len(conversationIDs)), conversations, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user