fix: sync linked discussion guest support

This commit is contained in:
A 2026-07-11 23:18:24 +08:00
parent 5f7c0b9804
commit 9f73dc20da
27 changed files with 1004 additions and 30 deletions

View file

@ -121,6 +121,40 @@ func (s *Service) GetChannel(ctx context.Context, userID, channelID int64) (doma
return s.channels.GetChannel(ctx, userID, channelID)
}
type linkedDiscussionChannelStore interface {
GetLinkedDiscussionChannel(ctx context.Context, viewerUserID, sourceChannelID int64) (domain.ChannelView, error)
}
type discussionReadTargetStore interface {
ResolveDiscussionReadTarget(ctx context.Context, userID, sourceChannelID int64, sourceMessageID, readMaxID int) (domain.ChannelDiscussionReadTarget, error)
}
// GetLinkedDiscussionChannel exposes the linked discussion peer to members of
// its source broadcast without broadening ordinary private-group visibility.
func (s *Service) GetLinkedDiscussionChannel(ctx context.Context, userID, sourceChannelID int64) (domain.ChannelView, error) {
if s == nil || s.channels == nil || userID == 0 || sourceChannelID == 0 {
return domain.ChannelView{}, domain.ErrChannelInvalid
}
provider, ok := s.channels.(linkedDiscussionChannelStore)
if !ok {
return domain.ChannelView{}, domain.ErrChannelInvalid
}
return provider.GetLinkedDiscussionChannel(ctx, userID, sourceChannelID)
}
// ResolveDiscussionReadTarget returns only the linked target/root/read boundary
// required by messages.readDiscussion, avoiding the full discussion payload.
func (s *Service) ResolveDiscussionReadTarget(ctx context.Context, userID, sourceChannelID int64, sourceMessageID, readMaxID int) (domain.ChannelDiscussionReadTarget, error) {
if s == nil || s.channels == nil || userID == 0 || sourceChannelID == 0 || sourceMessageID <= 0 || readMaxID < 0 {
return domain.ChannelDiscussionReadTarget{}, domain.ErrChannelInvalid
}
provider, ok := s.channels.(discussionReadTargetStore)
if !ok {
return domain.ChannelDiscussionReadTarget{}, domain.ErrChannelInvalid
}
return provider.ResolveDiscussionReadTarget(ctx, userID, sourceChannelID, sourceMessageID, readMaxID)
}
// GetChannelReadModel returns the full channel view through a version-token guarded
// read model cache. It is intended for read-only RPC projection paths, not write
// permission checks.