feat: sync message translation support
This commit is contained in:
parent
cbccd6a8d9
commit
ea6cc72886
26 changed files with 1189 additions and 0 deletions
33
internal/rpc/translation_projection.go
Normal file
33
internal/rpc/translation_projection.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gotd/td/tg"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
func (r *Router) applyTranslationDisabledToUserFull(ctx context.Context, viewerUserID, peerUserID int64, full *tg.UserFull) error {
|
||||
if full == nil || r.deps.Translation == nil || viewerUserID == 0 || peerUserID == 0 {
|
||||
return nil
|
||||
}
|
||||
disabled, err := r.deps.Translation.PeerDisabled(ctx, viewerUserID, domain.Peer{Type: domain.PeerTypeUser, ID: peerUserID})
|
||||
if err != nil {
|
||||
return internalErr()
|
||||
}
|
||||
full.SetTranslationsDisabled(disabled)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Router) applyTranslationDisabledToChannelFull(ctx context.Context, viewerUserID, channelID int64, full *tg.ChannelFull) error {
|
||||
if full == nil || r.deps.Translation == nil || viewerUserID == 0 || channelID == 0 {
|
||||
return nil
|
||||
}
|
||||
disabled, err := r.deps.Translation.PeerDisabled(ctx, viewerUserID, domain.Peer{Type: domain.PeerTypeChannel, ID: channelID})
|
||||
if err != nil {
|
||||
return internalErr()
|
||||
}
|
||||
full.SetTranslationsDisabled(disabled)
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue