summaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/federating_db.go161
-rw-r--r--internal/db/gtsmodel/activitystreams.go90
-rw-r--r--internal/db/gtsmodel/emoji.go1
-rw-r--r--internal/db/gtsmodel/mediaattachment.go10
-rw-r--r--internal/db/gtsmodel/status.go12
-rw-r--r--internal/db/pg.go17
6 files changed, 195 insertions, 96 deletions
diff --git a/internal/db/federating_db.go b/internal/db/federating_db.go
index 5b05967ea..16e3262ae 100644
--- a/internal/db/federating_db.go
+++ b/internal/db/federating_db.go
@@ -25,7 +25,6 @@ import (
"sync"
"github.com/go-fed/activity/pub"
- "github.com/go-fed/activity/streams"
"github.com/go-fed/activity/streams/vocab"
"github.com/superseriousbusiness/gotosocial/internal/config"
)
@@ -49,7 +48,19 @@ func newFederatingDB(db DB, config *config.Config) pub.Database {
/*
GO-FED DB INTERFACE-IMPLEMENTING FUNCTIONS
*/
-func (f *federatingDB) Lock(ctx context.Context, id *url.URL) error {
+
+// Lock takes a lock for the object at the specified id. If an error
+// is returned, the lock must not have been taken.
+//
+// The lock must be able to succeed for an id that does not exist in
+// the database. This means acquiring the lock does not guarantee the
+// entry exists in the database.
+//
+// Locks are encouraged to be lightweight and in the Go layer, as some
+// processes require tight loops acquiring and releasing locks.
+//
+// Used to ensure race conditions in multiple requests do not occur.
+func (f *federatingDB) Lock(c context.Context, id *url.URL) error {
// Before any other Database methods are called, the relevant `id`
// entries are locked to allow for fine-grained concurrency.
@@ -65,7 +76,11 @@ func (f *federatingDB) Lock(ctx context.Context, id *url.URL) error {
return nil
}
-func (f *federatingDB) Unlock(ctx context.Context, id *url.URL) error {
+// Unlock makes the lock for the object at the specified id available.
+// If an error is returned, the lock must have still been freed.
+//
+// Used to ensure race conditions in multiple requests do not occur.
+func (f *federatingDB) Unlock(c context.Context, id *url.URL) error {
// Once Go-Fed is done calling Database methods, the relevant `id`
// entries are unlocked.
@@ -78,82 +93,168 @@ func (f *federatingDB) Unlock(ctx context.Context, id *url.URL) error {
return nil
}
-func (f *federatingDB) InboxContains(ctx context.Context, inbox *url.URL, id *url.URL) (bool, error) {
+// InboxContains returns true if the OrderedCollection at 'inbox'
+// contains the specified 'id'.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) InboxContains(c context.Context, inbox, id *url.URL) (contains bool, err error) {
return false, nil
}
-func (f *federatingDB) GetInbox(ctx context.Context, inboxIRI *url.URL) (inbox vocab.ActivityStreamsOrderedCollectionPage, err error) {
+// GetInbox returns the first ordered collection page of the outbox at
+// the specified IRI, for prepending new items.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) GetInbox(c context.Context, inboxIRI *url.URL) (inbox vocab.ActivityStreamsOrderedCollectionPage, err error) {
return nil, nil
}
-func (f *federatingDB) SetInbox(ctx context.Context, inbox vocab.ActivityStreamsOrderedCollectionPage) error {
+// SetInbox saves the inbox value given from GetInbox, with new items
+// prepended. Note that the new items must not be added as independent
+// database entries. Separate calls to Create will do that.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) SetInbox(c context.Context, inbox vocab.ActivityStreamsOrderedCollectionPage) error {
return nil
}
-func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (owns bool, err error) {
- return id.Host == f.config.Host, nil
+// Owns returns true if the database has an entry for the IRI and it
+// exists in the database.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Owns(c context.Context, id *url.URL) (owns bool, err error) {
+ return false, nil
}
-func (f *federatingDB) ActorForOutbox(ctx context.Context, outboxIRI *url.URL) (actorIRI *url.URL, err error) {
+// ActorForOutbox fetches the actor's IRI for the given outbox IRI.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) ActorForOutbox(c context.Context, outboxIRI *url.URL) (actorIRI *url.URL, err error) {
return nil, nil
}
-func (f *federatingDB) ActorForInbox(ctx context.Context, inboxIRI *url.URL) (actorIRI *url.URL, err error) {
+// ActorForInbox fetches the actor's IRI for the given outbox IRI.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) ActorForInbox(c context.Context, inboxIRI *url.URL) (actorIRI *url.URL, err error) {
return nil, nil
}
-func (f *federatingDB) OutboxForInbox(ctx context.Context, inboxIRI *url.URL) (outboxIRI *url.URL, err error) {
+// OutboxForInbox fetches the corresponding actor's outbox IRI for the
+// actor's inbox IRI.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) OutboxForInbox(c context.Context, inboxIRI *url.URL) (outboxIRI *url.URL, err error) {
return nil, nil
}
-func (f *federatingDB) Exists(ctx context.Context, id *url.URL) (exists bool, err error) {
+// Exists returns true if the database has an entry for the specified
+// id. It may not be owned by this application instance.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Exists(c context.Context, id *url.URL) (exists bool, err error) {
return false, nil
}
-func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type, err error) {
+// Get returns the database entry for the specified id.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Get(c context.Context, id *url.URL) (value vocab.Type, err error) {
return nil, nil
}
-func (f *federatingDB) Create(ctx context.Context, asType vocab.Type) error {
- t, err := streams.NewTypeResolver()
- if err != nil {
- return err
- }
- if err := t.Resolve(ctx, asType); err != nil {
- return err
- }
- asType.GetTypeName()
+// Create adds a new entry to the database which must be able to be
+// keyed by its id.
+//
+// Note that Activity values received from federated peers may also be
+// created in the database this way if the Federating Protocol is
+// enabled. The client may freely decide to store only the id instead of
+// the entire value.
+//
+// The library makes this call only after acquiring a lock first.
+//
+// Under certain conditions and network activities, Create may be called
+// multiple times for the same ActivityStreams object.
+func (f *federatingDB) Create(c context.Context, asType vocab.Type) error {
return nil
}
-func (f *federatingDB) Update(ctx context.Context, asType vocab.Type) error {
+// Update sets an existing entry to the database based on the value's
+// id.
+//
+// Note that Activity values received from federated peers may also be
+// updated in the database this way if the Federating Protocol is
+// enabled. The client may freely decide to store only the id instead of
+// the entire value.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Update(c context.Context, asType vocab.Type) error {
return nil
}
-func (f *federatingDB) Delete(ctx context.Context, id *url.URL) error {
+// Delete removes the entry with the given id.
+//
+// Delete is only called for federated objects. Deletes from the Social
+// Protocol instead call Update to create a Tombstone.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Delete(c context.Context, id *url.URL) error {
return nil
}
-func (f *federatingDB) GetOutbox(ctx context.Context, outboxIRI *url.URL) (inbox vocab.ActivityStreamsOrderedCollectionPage, err error) {
+// GetOutbox returns the first ordered collection page of the outbox
+// at the specified IRI, for prepending new items.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) GetOutbox(c context.Context, outboxIRI *url.URL) (inbox vocab.ActivityStreamsOrderedCollectionPage, err error) {
return nil, nil
}
-func (f *federatingDB) SetOutbox(ctx context.Context, outbox vocab.ActivityStreamsOrderedCollectionPage) error {
+// SetOutbox saves the outbox value given from GetOutbox, with new items
+// prepended. Note that the new items must not be added as independent
+// database entries. Separate calls to Create will do that.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) SetOutbox(c context.Context, outbox vocab.ActivityStreamsOrderedCollectionPage) error {
return nil
}
-func (f *federatingDB) NewID(ctx context.Context, t vocab.Type) (id *url.URL, err error) {
+// NewID creates a new IRI id for the provided activity or object. The
+// implementation does not need to set the 'id' property and simply
+// needs to determine the value.
+//
+// The go-fed library will handle setting the 'id' property on the
+// activity or object provided with the value returned.
+func (f *federatingDB) NewID(c context.Context, t vocab.Type) (id *url.URL, err error) {
return nil, nil
}
-func (f *federatingDB) Followers(ctx context.Context, actorIRI *url.URL) (followers vocab.ActivityStreamsCollection, err error) {
+// Followers obtains the Followers Collection for an actor with the
+// given id.
+//
+// If modified, the library will then call Update.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Followers(c context.Context, actorIRI *url.URL) (followers vocab.ActivityStreamsCollection, err error) {
return nil, nil
}
-func (f *federatingDB) Following(ctx context.Context, actorIRI *url.URL) (followers vocab.ActivityStreamsCollection, err error) {
+// Following obtains the Following Collection for an actor with the
+// given id.
+//
+// If modified, the library will then call Update.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (followers vocab.ActivityStreamsCollection, err error) {
return nil, nil
}
-func (f *federatingDB) Liked(ctx context.Context, actorIRI *url.URL) (followers vocab.ActivityStreamsCollection, err error) {
+// Liked obtains the Liked Collection for an actor with the
+// given id.
+//
+// If modified, the library will then call Update.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) Liked(c context.Context, actorIRI *url.URL) (followers vocab.ActivityStreamsCollection, err error) {
return nil, nil
}
diff --git a/internal/db/gtsmodel/activitystreams.go b/internal/db/gtsmodel/activitystreams.go
index 059588a57..f852340bb 100644
--- a/internal/db/gtsmodel/activitystreams.go
+++ b/internal/db/gtsmodel/activitystreams.go
@@ -22,29 +22,29 @@ package gtsmodel
type ActivityStreamsObject string
const (
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-article
+ // ActivityStreamsArticle https://www.w3.org/TR/activitystreams-vocabulary/#dfn-article
ActivityStreamsArticle ActivityStreamsObject = "Article"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-audio
+ // ActivityStreamsAudio https://www.w3.org/TR/activitystreams-vocabulary/#dfn-audio
ActivityStreamsAudio ActivityStreamsObject = "Audio"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-document
+ // ActivityStreamsDocument https://www.w3.org/TR/activitystreams-vocabulary/#dfn-document
ActivityStreamsDocument ActivityStreamsObject = "Event"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event
+ // ActivityStreamsEvent https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event
ActivityStreamsEvent ActivityStreamsObject = "Event"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-image
+ // ActivityStreamsImage https://www.w3.org/TR/activitystreams-vocabulary/#dfn-image
ActivityStreamsImage ActivityStreamsObject = "Image"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note
+ // ActivityStreamsNote https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note
ActivityStreamsNote ActivityStreamsObject = "Note"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-page
+ // ActivityStreamsPage https://www.w3.org/TR/activitystreams-vocabulary/#dfn-page
ActivityStreamsPage ActivityStreamsObject = "Page"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-place
+ // ActivityStreamsPlace https://www.w3.org/TR/activitystreams-vocabulary/#dfn-place
ActivityStreamsPlace ActivityStreamsObject = "Place"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-profile
+ // ActivityStreamsProfile https://www.w3.org/TR/activitystreams-vocabulary/#dfn-profile
ActivityStreamsProfile ActivityStreamsObject = "Profile"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-relationship
+ // ActivityStreamsRelationship https://www.w3.org/TR/activitystreams-vocabulary/#dfn-relationship
ActivityStreamsRelationship ActivityStreamsObject = "Relationship"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tombstone
+ // ActivityStreamsTombstone https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tombstone
ActivityStreamsTombstone ActivityStreamsObject = "Tombstone"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-video
+ // ActivityStreamsVideo https://www.w3.org/TR/activitystreams-vocabulary/#dfn-video
ActivityStreamsVideo ActivityStreamsObject = "Video"
)
@@ -52,15 +52,15 @@ const (
type ActivityStreamsActor string
const (
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-application
+ // ActivityStreamsApplication https://www.w3.org/TR/activitystreams-vocabulary/#dfn-application
ActivityStreamsApplication ActivityStreamsActor = "Application"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-group
+ // ActivityStreamsGroup https://www.w3.org/TR/activitystreams-vocabulary/#dfn-group
ActivityStreamsGroup ActivityStreamsActor = "Group"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-organization
+ // ActivityStreamsOrganization https://www.w3.org/TR/activitystreams-vocabulary/#dfn-organization
ActivityStreamsOrganization ActivityStreamsActor = "Organization"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person
+ // ActivityStreamsPerson https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person
ActivityStreamsPerson ActivityStreamsActor = "Person"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-service
+ // ActivityStreamsService https://www.w3.org/TR/activitystreams-vocabulary/#dfn-service
ActivityStreamsService ActivityStreamsActor = "Service"
)
@@ -68,60 +68,60 @@ const (
type ActivityStreamsActivity string
const (
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accept
+ // ActivityStreamsAccept https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accept
ActivityStreamsAccept ActivityStreamsActivity = "Accept"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-add
+ // ActivityStreamsAdd https://www.w3.org/TR/activitystreams-vocabulary/#dfn-add
ActivityStreamsAdd ActivityStreamsActivity = "Add"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce
+ // ActivityStreamsAnnounce https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce
ActivityStreamsAnnounce ActivityStreamsActivity = "Announce"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-arrive
+ // ActivityStreamsArrive https://www.w3.org/TR/activitystreams-vocabulary/#dfn-arrive
ActivityStreamsArrive ActivityStreamsActivity = "Arrive"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-block
+ // ActivityStreamsBlock https://www.w3.org/TR/activitystreams-vocabulary/#dfn-block
ActivityStreamsBlock ActivityStreamsActivity = "Block"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create
+ // ActivityStreamsCreate https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create
ActivityStreamsCreate ActivityStreamsActivity = "Create"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete
+ // ActivityStreamsDelete https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete
ActivityStreamsDelete ActivityStreamsActivity = "Delete"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-dislike
+ // ActivityStreamsDislike https://www.w3.org/TR/activitystreams-vocabulary/#dfn-dislike
ActivityStreamsDislike ActivityStreamsActivity = "Dislike"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-flag
+ // ActivityStreamsFlag https://www.w3.org/TR/activitystreams-vocabulary/#dfn-flag
ActivityStreamsFlag ActivityStreamsActivity = "Flag"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow
+ // ActivityStreamsFollow https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow
ActivityStreamsFollow ActivityStreamsActivity = "Follow"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-ignore
+ // ActivityStreamsIgnore https://www.w3.org/TR/activitystreams-vocabulary/#dfn-ignore
ActivityStreamsIgnore ActivityStreamsActivity = "Ignore"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-invite
+ // ActivityStreamsInvite https://www.w3.org/TR/activitystreams-vocabulary/#dfn-invite
ActivityStreamsInvite ActivityStreamsActivity = "Invite"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-join
+ // ActivityStreamsJoin https://www.w3.org/TR/activitystreams-vocabulary/#dfn-join
ActivityStreamsJoin ActivityStreamsActivity = "Join"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-leave
+ // ActivityStreamsLeave https://www.w3.org/TR/activitystreams-vocabulary/#dfn-leave
ActivityStreamsLeave ActivityStreamsActivity = "Leave"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like
+ // ActivityStreamsLike https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like
ActivityStreamsLike ActivityStreamsActivity = "Like"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-listen
+ // ActivityStreamsListen https://www.w3.org/TR/activitystreams-vocabulary/#dfn-listen
ActivityStreamsListen ActivityStreamsActivity = "Listen"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-move
+ // ActivityStreamsMove https://www.w3.org/TR/activitystreams-vocabulary/#dfn-move
ActivityStreamsMove ActivityStreamsActivity = "Move"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-offer
+ // ActivityStreamsOffer https://www.w3.org/TR/activitystreams-vocabulary/#dfn-offer
ActivityStreamsOffer ActivityStreamsActivity = "Offer"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-question
+ // ActivityStreamsQuestion https://www.w3.org/TR/activitystreams-vocabulary/#dfn-question
ActivityStreamsQuestion ActivityStreamsActivity = "Question"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-reject
+ // ActivityStreamsReject https://www.w3.org/TR/activitystreams-vocabulary/#dfn-reject
ActivityStreamsReject ActivityStreamsActivity = "Reject"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-read
+ // ActivityStreamsRead https://www.w3.org/TR/activitystreams-vocabulary/#dfn-read
ActivityStreamsRead ActivityStreamsActivity = "Read"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-remove
+ // ActivityStreamsRemove https://www.w3.org/TR/activitystreams-vocabulary/#dfn-remove
ActivityStreamsRemove ActivityStreamsActivity = "Remove"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativereject
+ // ActivityStreamsTentativeReject https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativereject
ActivityStreamsTentativeReject ActivityStreamsActivity = "TentativeReject"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativeaccept
+ // ActivityStreamsTentativeAccept https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativeaccept
ActivityStreamsTentativeAccept ActivityStreamsActivity = "TentativeAccept"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-travel
+ // ActivityStreamsTravel https://www.w3.org/TR/activitystreams-vocabulary/#dfn-travel
ActivityStreamsTravel ActivityStreamsActivity = "Travel"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-undo
+ // ActivityStreamsUndo https://www.w3.org/TR/activitystreams-vocabulary/#dfn-undo
ActivityStreamsUndo ActivityStreamsActivity = "Undo"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update
+ // ActivityStreamsUpdate https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update
ActivityStreamsUpdate ActivityStreamsActivity = "Update"
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-view
+ // ActivityStreamsView https://www.w3.org/TR/activitystreams-vocabulary/#dfn-view
ActivityStreamsView ActivityStreamsActivity = "View"
)
diff --git a/internal/db/gtsmodel/emoji.go b/internal/db/gtsmodel/emoji.go
index da1e2e02c..c11e2e6b0 100644
--- a/internal/db/gtsmodel/emoji.go
+++ b/internal/db/gtsmodel/emoji.go
@@ -20,6 +20,7 @@ package gtsmodel
import "time"
+// Emoji represents a custom emoji that's been uploaded through the admin UI, and is useable by instance denizens.
type Emoji struct {
// database ID of this emoji
ID string `pg:"type:uuid,default:gen_random_uuid(),pk,notnull"`
diff --git a/internal/db/gtsmodel/mediaattachment.go b/internal/db/gtsmodel/mediaattachment.go
index d2b028b18..751956252 100644
--- a/internal/db/gtsmodel/mediaattachment.go
+++ b/internal/db/gtsmodel/mediaattachment.go
@@ -93,13 +93,13 @@ type Thumbnail struct {
type ProcessingStatus int
const (
- // ProcessingStatusReceived: the attachment has been received and is awaiting processing. No thumbnail available yet.
+ // ProcessingStatusReceived indicates the attachment has been received and is awaiting processing. No thumbnail available yet.
ProcessingStatusReceived ProcessingStatus = 0
- // ProcessingStatusProcessing: the attachment is currently being processed. Thumbnail is available but full media is not.
+ // ProcessingStatusProcessing indicates the attachment is currently being processed. Thumbnail is available but full media is not.
ProcessingStatusProcessing ProcessingStatus = 1
- // ProcessingStatusProcessed: the attachment has been fully processed and is ready to be served.
+ // ProcessingStatusProcessed indicates the attachment has been fully processed and is ready to be served.
ProcessingStatusProcessed ProcessingStatus = 2
- // ProcessingStatusError: something went wrong processing the attachment and it won't be tried again--these can be deleted.
+ // ProcessingStatusError indicates something went wrong processing the attachment and it won't be tried again--these can be deleted.
ProcessingStatusError ProcessingStatus = 666
)
@@ -142,6 +142,8 @@ type Original struct {
Aspect float64
}
+// Focus describes the 'center' of the image for display purposes.
+// X and Y should each be between -1 and 1
type Focus struct {
X float32
Y float32
diff --git a/internal/db/gtsmodel/status.go b/internal/db/gtsmodel/status.go
index 3b4b84405..06ef61760 100644
--- a/internal/db/gtsmodel/status.go
+++ b/internal/db/gtsmodel/status.go
@@ -95,17 +95,17 @@ type Status struct {
type Visibility string
const (
- // This status will be visible to everyone on all timelines.
+ // VisibilityPublic means this status will be visible to everyone on all timelines.
VisibilityPublic Visibility = "public"
- // This status will be visible to everyone, but will only show on home timeline to followers, and in lists.
+ // VisibilityUnlocked means this status will be visible to everyone, but will only show on home timeline to followers, and in lists.
VisibilityUnlocked Visibility = "unlocked"
- // This status is viewable to followers only.
+ // VisibilityFollowersOnly means this status is viewable to followers only.
VisibilityFollowersOnly Visibility = "followers_only"
- // This status is visible to mutual followers only.
+ // VisibilityMutualsOnly means this status is visible to mutual followers only.
VisibilityMutualsOnly Visibility = "mutuals_only"
- // This status is visible only to mentioned recipients
+ // VisibilityDirect means this status is visible only to mentioned recipients
VisibilityDirect Visibility = "direct"
- // Default visibility to use when no other setting can be found
+ // VisibilityDefault is used when no other setting can be found
VisibilityDefault Visibility = "public"
)
diff --git a/internal/db/pg.go b/internal/db/pg.go
index a12529d00..24a57d8a5 100644
--- a/internal/db/pg.go
+++ b/internal/db/pg.go
@@ -574,9 +574,8 @@ func (ps *postgresService) Blocked(account1 string, account2 string) (bool, erro
if err == pg.ErrNoRows {
blocked = false
return blocked, nil
- } else {
- return blocked, err
}
+ return blocked, err
}
blocked = true
return blocked, nil
@@ -597,9 +596,8 @@ func (ps *postgresService) StatusVisible(targetStatus *gtsmodel.Status, targetAc
l.Debug("target user could not be selected")
if err == pg.ErrNoRows {
return false, ErrNoEntries{}
- } else {
- return false, err
}
+ return false, err
}
// if target user is disabled, not yet approved, or not confirmed then don't show the status
@@ -635,10 +633,9 @@ func (ps *postgresService) StatusVisible(targetStatus *gtsmodel.Status, targetAc
if err == pg.ErrNoRows {
l.Debug("requesting account is local but there's no corresponding user")
return false, nil
- } else {
- l.Debugf("requesting account is local but there was an error getting the corresponding user: %s", err)
- return false, err
}
+ l.Debugf("requesting account is local but there was an error getting the corresponding user: %s", err)
+ return false, err
}
// okay, user exists, so make sure it has full privileges/is confirmed/approved
if requestingUser.Disabled || !requestingUser.Approved || requestingUser.ConfirmedAt.IsZero() {
@@ -751,9 +748,8 @@ func (ps *postgresService) Mutuals(account1 *gtsmodel.Account, account2 *gtsmode
if err != nil {
if err == pg.ErrNoRows {
return false, nil
- } else {
- return false, err
}
+ return false, err
}
// make sure account 2 follows account 1
@@ -761,9 +757,8 @@ func (ps *postgresService) Mutuals(account1 *gtsmodel.Account, account2 *gtsmode
if err != nil {
if err == pg.ErrNoRows {
return false, nil
- } else {
- return false, err
}
+ return false, err
}
return f1 && f2, nil