summaryrefslogtreecommitdiff
path: root/internal/gtsmodel/domainblock.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2021-09-03 10:27:40 +0100
committerLibravatar GitHub <noreply@github.com>2021-09-03 10:27:40 +0100
commit25edd57eaf3eecf0b449a4dabb5b5fc5d6ae7687 (patch)
treeb6cffb65d46a07f59d5393a257973910d4116227 /internal/gtsmodel/domainblock.go
parentsession name fix (#185) (diff)
parentreview changes (diff)
downloadgotosocial-25edd57eaf3eecf0b449a4dabb5b5fc5d6ae7687.tar.xz
Merge pull request #186 from superseriousbusiness/struct_validation
Struct validation
Diffstat (limited to 'internal/gtsmodel/domainblock.go')
-rw-r--r--internal/gtsmodel/domainblock.go29
1 files changed, 10 insertions, 19 deletions
diff --git a/internal/gtsmodel/domainblock.go b/internal/gtsmodel/domainblock.go
index 784e665a5..4c72b842a 100644
--- a/internal/gtsmodel/domainblock.go
+++ b/internal/gtsmodel/domainblock.go
@@ -22,23 +22,14 @@ import "time"
// DomainBlock represents a federation block against a particular domain
type DomainBlock struct {
- // ID of this block in the database
- ID string `bun:"type:CHAR(26),pk,notnull,unique"`
- // blocked domain
- Domain string `bun:",pk,notnull,unique"`
- // When was this block created
- CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
- // When was this block updated
- UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
- // Account ID of the creator of this block
- CreatedByAccountID string `bun:"type:CHAR(26),notnull"`
- CreatedByAccount *Account `bun:"rel:belongs-to"`
- // Private comment on this block, viewable to admins
- PrivateComment string `bun:",nullzero"`
- // Public comment on this block, viewable (optionally) by everyone
- PublicComment string `bun:",nullzero"`
- // whether the domain name should appear obfuscated when displaying it publicly
- Obfuscate bool
- // if this block was created through a subscription, what's the subscription ID?
- SubscriptionID string `bun:"type:CHAR(26),nullzero"`
+ ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
+ CreatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created
+ UpdatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated
+ Domain string `validate:"required,fqdn" bun:",nullzero,notnull"` // domain to block. Eg. 'whatever.com'
+ CreatedByAccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // Account ID of the creator of this block
+ CreatedByAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to createdByAccountID
+ PrivateComment string `validate:"-" bun:",nullzero"` // Private comment on this block, viewable to admins
+ PublicComment string `validate:"-" bun:",nullzero"` // Public comment on this block, viewable (optionally) by everyone
+ Obfuscate bool `validate:"-" bun:",nullzero,default:false"` // whether the domain name should appear obfuscated when displaying it publicly
+ SubscriptionID string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // if this block was created through a subscription, what's the subscription ID?
}