disabling marksbot when third-party verifications if turned off
This commit is contained in:
parent
2491088e81
commit
818c9a58a3
7 changed files with 158 additions and 1 deletions
|
|
@ -27,6 +27,10 @@ type Service struct {
|
|||
privacy userprojection.PrivacyEvaluator
|
||||
freezes userprojection.AccountFreezeProvider
|
||||
projector *userprojection.Projector
|
||||
// hideThirdPartyVerification mirrors config.HideThirdPartyVerification:
|
||||
// while true, ResolveUsername never resolves @marksbot
|
||||
// (domain.VerifierBotUserID), so a client cannot discover it by username.
|
||||
hideThirdPartyVerification bool
|
||||
}
|
||||
|
||||
type usernameAvailabilityStore interface {
|
||||
|
|
@ -64,6 +68,12 @@ func WithAccountFreezeProvider(p userprojection.AccountFreezeProvider) Option {
|
|||
return func(s *Service) { s.freezes = p }
|
||||
}
|
||||
|
||||
// WithHideThirdPartyVerification mirrors config.HideThirdPartyVerification:
|
||||
// while true, ResolveUsername treats @marksbot as not found.
|
||||
func WithHideThirdPartyVerification(hidden bool) Option {
|
||||
return func(s *Service) { s.hideThirdPartyVerification = hidden }
|
||||
}
|
||||
|
||||
const (
|
||||
minUsernameLen = 5
|
||||
maxUsernameLen = 32
|
||||
|
|
@ -617,6 +627,9 @@ func (s *Service) ResolveUsername(ctx context.Context, currentUserID int64, user
|
|||
if err != nil || !found {
|
||||
return u, found, err
|
||||
}
|
||||
if s.hideThirdPartyVerification && u.ID == domain.VerifierBotUserID {
|
||||
return domain.User{}, false, nil
|
||||
}
|
||||
s.putCachedUsers(ctx, u)
|
||||
u, err = s.projectOne(ctx, currentUserID, u)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue