From c1375ca5c1d5a8a645151cedfced5a336f6b7467 Mon Sep 17 00:00:00 2001 From: Daenney Date: Sun, 6 Aug 2023 12:22:40 +0200 Subject: [chore] Remove go-playground/validator (#2069) * [chore] Remove go-playground/validator It turns out we're not actually using the validator code. This is a remnant from when we intended to use it, but the presence of it and its struct tags creates the illusion we're validating a lot of things we're not. It resulted in some confusion when we were trying to figure out language valdiation. Remove all this code, so that only the validation functions from the validate package we actually use remain. I'm not touching the struct tags in the migrations in order to avoid things potentially thinking migrations need to be re-run. * [chore] Bring back a struct tag on api The validate on internal/api is Gin doing form validation, not the validator from go-playground/validator. --- internal/gtsmodel/mention.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'internal/gtsmodel/mention.go') diff --git a/internal/gtsmodel/mention.go b/internal/gtsmodel/mention.go index 9ad9204eb..fb7f3b51a 100644 --- a/internal/gtsmodel/mention.go +++ b/internal/gtsmodel/mention.go @@ -24,17 +24,17 @@ import ( // Mention refers to the 'tagging' or 'mention' of a user within a status. type Mention struct { - 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:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created - UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated - StatusID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // ID of the status this mention originates from - Status *Status `validate:"-" bun:"rel:belongs-to"` // status referred to by statusID - OriginAccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // ID of the mention creator account - OriginAccountURI string `validate:"url" bun:",nullzero,notnull"` // ActivityPub URI of the originator/creator of the mention - OriginAccount *Account `validate:"-" bun:"rel:belongs-to"` // account referred to by originAccountID - TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // Mention target/receiver account ID - TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // account referred to by targetAccountID - Silent *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Prevent this mention from generating a notification? + ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database + CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created + UpdatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated + StatusID string `bun:"type:CHAR(26),nullzero,notnull"` // ID of the status this mention originates from + Status *Status `bun:"rel:belongs-to"` // status referred to by statusID + OriginAccountID string `bun:"type:CHAR(26),nullzero,notnull"` // ID of the mention creator account + OriginAccountURI string `bun:",nullzero,notnull"` // ActivityPub URI of the originator/creator of the mention + OriginAccount *Account `bun:"rel:belongs-to"` // account referred to by originAccountID + TargetAccountID string `bun:"type:CHAR(26),nullzero,notnull"` // Mention target/receiver account ID + TargetAccount *Account `bun:"rel:belongs-to"` // account referred to by targetAccountID + Silent *bool `bun:",nullzero,notnull,default:false"` // Prevent this mention from generating a notification? /* NON-DATABASE CONVENIENCE FIELDS @@ -48,15 +48,15 @@ type Mention struct { // @whatever_username@example.org // // This will not be put in the database, it's just for convenience. - NameString string `validate:"-" bun:"-"` + NameString string `bun:"-"` // TargetAccountURI is the AP ID (uri) of the user mentioned. // // This will not be put in the database, it's just for convenience. - TargetAccountURI string `validate:"-" bun:"-"` + TargetAccountURI string `bun:"-"` // TargetAccountURL is the web url of the user mentioned. // // This will not be put in the database, it's just for convenience. - TargetAccountURL string `validate:"-" bun:"-"` + TargetAccountURL string `bun:"-"` // A pointer to the gtsmodel account of the mentioned account. } -- cgit v1.2.3