From cc48294c31a76e94fa879ad0d8d5dbd7e94c651b Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 15 May 2021 11:58:11 +0200 Subject: Inbox post (#22) Inbox POST from federated servers now working for statuses and follow requests. Follow request client API added. Start work on federating outgoing messages. Other fixes and changes/tidying up. --- internal/gtsmodel/account.go | 6 +++--- internal/gtsmodel/mention.go | 16 ++++++++++++++-- internal/gtsmodel/status.go | 18 +++++++++++++++++- internal/gtsmodel/tag.go | 2 ++ 4 files changed, 36 insertions(+), 6 deletions(-) (limited to 'internal/gtsmodel') diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go index 1903216f8..56c401e62 100644 --- a/internal/gtsmodel/account.go +++ b/internal/gtsmodel/account.go @@ -76,15 +76,15 @@ type Account struct { */ // Does this account need an approval for new followers? - Locked bool `pg:",default:true"` + Locked bool `pg:",default:'true'"` // Should this account be shown in the instance's profile directory? Discoverable bool // Default post privacy for this account Privacy Visibility // Set posts from this account to sensitive by default? - Sensitive bool `pg:",default:false"` + Sensitive bool `pg:",default:'false'"` // What language does this account post in? - Language string `pg:",default:en"` + Language string `pg:",default:'en'"` /* ACTIVITYPUB THINGS diff --git a/internal/gtsmodel/mention.go b/internal/gtsmodel/mention.go index 18eb11082..8e56a1b36 100644 --- a/internal/gtsmodel/mention.go +++ b/internal/gtsmodel/mention.go @@ -30,10 +30,22 @@ type Mention struct { CreatedAt time.Time `pg:"type:timestamp,notnull,default:now()"` // When was this mention last updated? UpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"` - // Who created this mention? + // What's the internal account ID of the originator of the mention? OriginAccountID string `pg:",notnull"` - // Who does this mention target? + // What's the AP URI of the originator of the mention? + OriginAccountURI string `pg:",notnull"` + // What's the internal account ID of the mention target? TargetAccountID string `pg:",notnull"` // Prevent this mention from generating a notification? Silent bool + // NameString is for putting in the namestring of the mentioned user + // before the mention is dereferenced. Should be in a form along the lines of: + // @whatever_username@example.org + // + // This will not be put in the database, it's just for convenience. + NameString string `pg:"-"` + // MentionedAccountURI is the AP ID (uri) of the user mentioned. + // + // This will not be put in the database, it's just for convenience. + MentionedAccountURI string `pg:"-"` } diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go index 55ae91599..8693bce30 100644 --- a/internal/gtsmodel/status.go +++ b/internal/gtsmodel/status.go @@ -71,12 +71,14 @@ type Status struct { Text string /* - NON-DATABASE FIELDS + INTERNAL MODEL NON-DATABASE FIELDS These are for convenience while passing the status around internally, but these fields should *never* be put in the db. */ + // Account that created this status + GTSAccount *Account `pg:"-"` // Mentions created in this status GTSMentions []*Mention `pg:"-"` // Hashtags used in this status @@ -93,6 +95,20 @@ type Status struct { GTSBoostedStatus *Status `pg:"-"` // Account of the boosted status GTSBoostedAccount *Account `pg:"-"` + + /* + AP NON-DATABASE FIELDS + + These are for convenience while passing the status around internally, + but these fields should *never* be put in the db. + */ + + // AP URI of the status being replied to. + // Useful when that status doesn't exist in the database yet and we still need to dereference it. + APReplyToStatusURI string `pg:"-"` + // The AP URI of the owner/creator of the status. + // Useful when that account doesn't exist in the database yet and we still need to dereference it. + APStatusOwnerURI string `pg:"-"` } // Visibility represents the visibility granularity of a status. diff --git a/internal/gtsmodel/tag.go b/internal/gtsmodel/tag.go index 83c471958..c1b0429d6 100644 --- a/internal/gtsmodel/tag.go +++ b/internal/gtsmodel/tag.go @@ -24,6 +24,8 @@ import "time" type Tag struct { // id of this tag in the database ID string `pg:",unique,type:uuid,default:gen_random_uuid(),pk,notnull"` + // Href of this tag, eg https://example.org/tags/somehashtag + URL string // name of this tag -- the tag without the hash part Name string `pg:",unique,pk,notnull"` // Which account ID is the first one we saw using this tag? -- cgit v1.2.3