admin: add account spam restriction (join/message gate)
Adds a narrower spam sanction alongside the existing account freeze: a restricted account keeps every existing membership and conversation, but cannot join new channels/groups (public join or invite link) and cannot start a new conversation with a non-contact. Reachable both as a standalone admin action and as a decision on a reported user's moderation case, with the same idempotent-supersession and appeal wiring freeze already has.
This commit is contained in:
parent
3ca8ef1a16
commit
f33e25af8d
32 changed files with 750 additions and 44 deletions
|
|
@ -576,8 +576,10 @@ func (f *fakeBotService) AdminExportBotToken(_ context.Context, botUserID int64)
|
|||
}
|
||||
|
||||
type fakeRestrictionStore struct {
|
||||
items map[int64]domain.AccountFreeze
|
||||
setCalls int
|
||||
items map[int64]domain.AccountFreeze
|
||||
setCalls int
|
||||
restrictionItems map[int64]domain.AccountRestriction
|
||||
restrictionSetCall int
|
||||
}
|
||||
|
||||
func (f *fakeRestrictionStore) GetAccountFreeze(_ context.Context, userID int64) (domain.AccountFreeze, bool, error) {
|
||||
|
|
@ -599,6 +601,25 @@ func (f *fakeRestrictionStore) SetAccountFreeze(_ context.Context, r domain.Acco
|
|||
return r, nil
|
||||
}
|
||||
|
||||
func (f *fakeRestrictionStore) GetAccountRestriction(_ context.Context, userID int64) (domain.AccountRestriction, bool, error) {
|
||||
if f.restrictionItems == nil {
|
||||
return domain.AccountRestriction{}, false, nil
|
||||
}
|
||||
r, ok := f.restrictionItems[userID]
|
||||
return r, ok, nil
|
||||
}
|
||||
|
||||
func (f *fakeRestrictionStore) SetAccountRestriction(_ context.Context, r domain.AccountRestriction) (domain.AccountRestriction, error) {
|
||||
if f.restrictionItems == nil {
|
||||
f.restrictionItems = map[int64]domain.AccountRestriction{}
|
||||
}
|
||||
f.restrictionSetCall++
|
||||
r.Version = f.restrictionItems[r.UserID].Version + 1
|
||||
r.UpdatedAt = fixedNow()
|
||||
f.restrictionItems[r.UserID] = r
|
||||
return r, nil
|
||||
}
|
||||
|
||||
type fakeBatchRestrictionStore struct {
|
||||
fakeRestrictionStore
|
||||
requests [][]int64
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue