diff --git a/internal/db/bundb/migrations/20250226013442_add_status_content_type/status.go b/internal/db/bundb/migrations/20250226013442_add_status_content_type/status.go index 411713708..93b747a62 100644 --- a/internal/db/bundb/migrations/20250226013442_add_status_content_type/status.go +++ b/internal/db/bundb/migrations/20250226013442_add_status_content_type/status.go @@ -68,12 +68,12 @@ type Status struct { CreatedWithApplication *gtsmodel.Application `bun:"rel:belongs-to"` // application corresponding to createdWithApplicationID ActivityStreamsType string `bun:",nullzero,notnull"` // What is the activitystreams type of this status? See: https://www.w3.org/TR/activitystreams-vocabulary/#object-types. Will probably almost always be Note but who knows!. Text string `bun:""` // Original text of the status without formatting + ContentType StatusContentType `bun:",nullzero"` // Content type used to process the original text of the status Federated *bool `bun:",notnull"` // This status will be federated beyond the local timeline(s) InteractionPolicy *gtsmodel.InteractionPolicy `bun:""` // InteractionPolicy for this status. If null then the default InteractionPolicy should be assumed for this status's Visibility. Always null for boost wrappers. PendingApproval *bool `bun:",nullzero,notnull,default:false"` // If true then status is a reply or boost wrapper that must be Approved by the reply-ee or boost-ee before being fully distributed. PreApproved bool `bun:"-"` // If true, then status is a reply to or boost wrapper of a status on our instance, has permission to do the interaction, and an Accept should be sent out for it immediately. Field not stored in the DB. ApprovedByURI string `bun:",nullzero"` // URI of an Accept Activity that approves the Announce or Create Activity that this status was/will be attached to. - ContentType StatusContentType `bun:",nullzero"` // TODO } type enumType int16 diff --git a/internal/db/bundb/migrations/20250226013442_add_status_content_type/statusedit.go b/internal/db/bundb/migrations/20250226013442_add_status_content_type/statusedit.go index bd4be1f53..c69e6ea7a 100644 --- a/internal/db/bundb/migrations/20250226013442_add_status_content_type/statusedit.go +++ b/internal/db/bundb/migrations/20250226013442_add_status_content_type/statusedit.go @@ -35,6 +35,7 @@ type StatusEdit struct { Content string `bun:""` // Content of status at time of edit; likely html-formatted but not guaranteed. ContentWarning string `bun:",nullzero"` // Content warning of status at time of edit. Text string `bun:""` // Original status text, without formatting, at time of edit. + ContentType StatusContentType `bun:",nullzero"` // Content type used to process the original text of the status. Language string `bun:",nullzero"` // Status language at time of edit. Sensitive *bool `bun:",nullzero,notnull,default:false"` // Status sensitive flag at time of edit. AttachmentIDs []string `bun:"attachments,array"` // Database IDs of media attachments associated with status at time of edit. @@ -44,7 +45,6 @@ type StatusEdit struct { PollVotes []int `bun:",array"` // Poll vote count at time of status edit, only set if poll votes were reset. StatusID string `bun:"type:CHAR(26),nullzero,notnull"` // The originating status ID this is a historical edit of. CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // The creation time of this version of the status content (according to receiving server). - ContentType StatusContentType `bun:",nullzero"` // TODO // We don't bother having a *gtsmodel.Status model here // as the StatusEdit is always just attached to a Status, // so it doesn't need a self-reference back to it. diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go index 852ba887b..c630e7790 100644 --- a/internal/gtsmodel/status.go +++ b/internal/gtsmodel/status.go @@ -69,12 +69,12 @@ type Status struct { CreatedWithApplication *Application `bun:"rel:belongs-to"` // application corresponding to createdWithApplicationID ActivityStreamsType string `bun:",nullzero,notnull"` // What is the activitystreams type of this status? See: https://www.w3.org/TR/activitystreams-vocabulary/#object-types. Will probably almost always be Note but who knows!. Text string `bun:""` // Original text of the status without formatting + ContentType StatusContentType `bun:",nullzero"` // Content type used to process the original text of the status Federated *bool `bun:",notnull"` // This status will be federated beyond the local timeline(s) InteractionPolicy *InteractionPolicy `bun:""` // InteractionPolicy for this status. If null then the default InteractionPolicy should be assumed for this status's Visibility. Always null for boost wrappers. PendingApproval *bool `bun:",nullzero,notnull,default:false"` // If true then status is a reply or boost wrapper that must be Approved by the reply-ee or boost-ee before being fully distributed. PreApproved bool `bun:"-"` // If true, then status is a reply to or boost wrapper of a status on our instance, has permission to do the interaction, and an Accept should be sent out for it immediately. Field not stored in the DB. ApprovedByURI string `bun:",nullzero"` // URI of an Accept Activity that approves the Announce or Create Activity that this status was/will be attached to. - ContentType StatusContentType `bun:",nullzero"` // TODO } // GetID implements timeline.Timelineable{}. diff --git a/internal/gtsmodel/statusedit.go b/internal/gtsmodel/statusedit.go index 68987cea9..0c434dba9 100644 --- a/internal/gtsmodel/statusedit.go +++ b/internal/gtsmodel/statusedit.go @@ -31,6 +31,7 @@ type StatusEdit struct { Content string `bun:""` // Content of status at time of edit; likely html-formatted but not guaranteed. ContentWarning string `bun:",nullzero"` // Content warning of status at time of edit. Text string `bun:""` // Original status text, without formatting, at time of edit. + ContentType StatusContentType `bun:",nullzero"` // Content type used to process the original text of the status. Language string `bun:",nullzero"` // Status language at time of edit. Sensitive *bool `bun:",nullzero,notnull,default:false"` // Status sensitive flag at time of edit. AttachmentIDs []string `bun:"attachments,array"` // Database IDs of media attachments associated with status at time of edit. @@ -40,7 +41,6 @@ type StatusEdit struct { PollVotes []int `bun:",array"` // Poll vote count at time of status edit, only set if poll votes were reset. StatusID string `bun:"type:CHAR(26),nullzero,notnull"` // The originating status ID this is a historical edit of. CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // The creation time of this version of the status content (according to receiving server). - ContentType StatusContentType `bun:",nullzero"` // TODO // We don't bother having a *gtsmodel.Status model here // as the StatusEdit is always just attached to a Status, // so it doesn't need a self-reference back to it. diff --git a/internal/processing/status/edit.go b/internal/processing/status/edit.go index f7547ebc0..710a5b726 100644 --- a/internal/processing/status/edit.go +++ b/internal/processing/status/edit.go @@ -368,7 +368,6 @@ func (p *Processor) processContentType( // Old statuses may not have a saved content type; update the status to the // user's preference and set this back on the form for later use. case accountDefaultContentType != "": - // TODO: is this conversion from string to StatusContentType safe status.ContentType = typeutils.APIContentTypeToContentType(apimodel.StatusContentType(accountDefaultContentType)) form.ContentType = apimodel.StatusContentType(accountDefaultContentType)