summaryrefslogtreecommitdiff
path: root/internal/typeutils
diff options
context:
space:
mode:
Diffstat (limited to 'internal/typeutils')
-rw-r--r--internal/typeutils/astointernal.go50
-rw-r--r--internal/typeutils/astointernal_test.go18
-rw-r--r--internal/typeutils/internal.go27
-rw-r--r--internal/typeutils/internaltoas.go6
-rw-r--r--internal/typeutils/internaltofrontend.go16
5 files changed, 76 insertions, 41 deletions
diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go
index e30608150..7ec45335d 100644
--- a/internal/typeutils/astointernal.go
+++ b/internal/typeutils/astointernal.go
@@ -99,29 +99,46 @@ func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable a
switch accountable.GetTypeName() {
case ap.ActorPerson, ap.ActorGroup, ap.ActorOrganization:
// people, groups, and organizations aren't bots
- acct.Bot = false
+ bot := false
+ acct.Bot = &bot
// apps and services are
case ap.ActorApplication, ap.ActorService:
- acct.Bot = true
+ bot := true
+ acct.Bot = &bot
default:
// we don't know what this is!
return nil, fmt.Errorf("type name %s not recognised or not convertible to ap.ActivityStreamsActor", accountable.GetTypeName())
}
acct.ActorType = accountable.GetTypeName()
+ // assume not memorial (todo)
+ memorial := false
+ acct.Memorial = &memorial
+
+ // assume not sensitive (todo)
+ sensitive := false
+ acct.Sensitive = &sensitive
+
+ // assume not hide collections (todo)
+ hideCollections := false
+ acct.HideCollections = &hideCollections
+
// locked aka manuallyApprovesFollowers
- acct.Locked = true // assume locked by default
+ locked := true
+ acct.Locked = &locked // assume locked by default
maf := accountable.GetActivityStreamsManuallyApprovesFollowers()
if maf != nil && maf.IsXMLSchemaBoolean() {
- acct.Locked = maf.Get()
+ locked = maf.Get()
+ acct.Locked = &locked
}
// discoverable
// default to false -- take custom value if it's set though
- acct.Discoverable = false
- discoverable, err := ap.ExtractDiscoverable(accountable)
+ discoverable := false
+ acct.Discoverable = &discoverable
+ d, err := ap.ExtractDiscoverable(accountable)
if err == nil {
- acct.Discoverable = discoverable
+ acct.Discoverable = &d
}
// url property
@@ -289,13 +306,20 @@ func (c *converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
// advanced visibility for this status
// TODO: a lot of work to be done here -- a new type needs to be created for this in go-fed/activity using ASTOOL
// for now we just set everything to true
- status.Federated = true
- status.Boostable = true
- status.Replyable = true
- status.Likeable = true
-
+ pinned := false
+ federated := true
+ boostable := true
+ replyable := true
+ likeable := true
+
+ status.Pinned = &pinned
+ status.Federated = &federated
+ status.Boostable = &boostable
+ status.Replyable = &replyable
+ status.Likeable = &likeable
// sensitive
- status.Sensitive = ap.ExtractSensitive(statusable)
+ sensitive := ap.ExtractSensitive(statusable)
+ status.Sensitive = &sensitive
// language
// we might be able to extract this from the contentMap field
diff --git a/internal/typeutils/astointernal_test.go b/internal/typeutils/astointernal_test.go
index dbd852d3f..7024018d6 100644
--- a/internal/typeutils/astointernal_test.go
+++ b/internal/typeutils/astointernal_test.go
@@ -51,9 +51,9 @@ func (suite *ASToInternalTestSuite) TestParsePerson() {
suite.Equal("Geoff Brando New Personson", acct.DisplayName)
suite.Equal("hey I'm a new person, your instance hasn't seen me yet uwu", acct.Note)
suite.Equal("https://unknown-instance.com/@brand_new_person", acct.URL)
- suite.True(acct.Discoverable)
+ suite.True(*acct.Discoverable)
suite.Equal("https://unknown-instance.com/users/brand_new_person#main-key", acct.PublicKeyURI)
- suite.False(acct.Locked)
+ suite.False(*acct.Locked)
}
func (suite *ASToInternalTestSuite) TestParsePublicStatus() {
@@ -145,10 +145,10 @@ func (suite *ASToInternalTestSuite) TestParseReplyWithMention() {
suite.Equal(inReplyToAccount.ID, status.InReplyToAccountID)
suite.Equal(inReplyToStatus.ID, status.InReplyToID)
suite.Equal(inReplyToStatus.URI, status.InReplyToURI)
- suite.True(status.Federated)
- suite.True(status.Boostable)
- suite.True(status.Replyable)
- suite.True(status.Likeable)
+ suite.True(*status.Federated)
+ suite.True(*status.Boostable)
+ suite.True(*status.Replyable)
+ suite.True(*status.Likeable)
suite.Equal(`<p><span class="h-card"><a href="http://localhost:8080/@the_mighty_zork" class="u-url mention">@<span>the_mighty_zork</span></a></span> nice there it is:</p><p><a href="http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/activity" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="ellipsis">social.pixie.town/users/f0x/st</span><span class="invisible">atuses/106221628567855262/activity</span></a></p>`, status.Content)
suite.Len(status.Mentions, 1)
m1 := status.Mentions[0]
@@ -177,9 +177,9 @@ func (suite *ASToInternalTestSuite) TestParseOwncastService() {
suite.Equal("https://owncast.example.org/logo/external", acct.HeaderRemoteURL)
suite.Equal("Rob's Owncast Server", acct.DisplayName)
suite.Equal("linux audio stuff ", acct.Note)
- suite.True(acct.Bot)
- suite.False(acct.Locked)
- suite.True(acct.Discoverable)
+ suite.True(*acct.Bot)
+ suite.False(*acct.Locked)
+ suite.True(*acct.Discoverable)
suite.Equal("https://owncast.example.org/federation/user/rgh", acct.URI)
suite.Equal("https://owncast.example.org/federation/user/rgh", acct.URL)
suite.Equal("https://owncast.example.org/federation/user/rgh/inbox", acct.InboxURI)
diff --git a/internal/typeutils/internal.go b/internal/typeutils/internal.go
index 0d49ea6b2..ce2c942fd 100644
--- a/internal/typeutils/internal.go
+++ b/internal/typeutils/internal.go
@@ -11,15 +11,18 @@ import (
)
func (c *converter) FollowRequestToFollow(ctx context.Context, f *gtsmodel.FollowRequest) *gtsmodel.Follow {
+ showReblogs := *f.ShowReblogs
+ notify := *f.Notify
+
return &gtsmodel.Follow{
ID: f.ID,
CreatedAt: f.CreatedAt,
UpdatedAt: f.UpdatedAt,
AccountID: f.AccountID,
TargetAccountID: f.TargetAccountID,
- ShowReblogs: f.ShowReblogs,
+ ShowReblogs: &showReblogs,
URI: f.URI,
- Notify: f.Notify,
+ Notify: &notify,
}
}
@@ -38,6 +41,13 @@ func (c *converter) StatusToBoost(ctx context.Context, s *gtsmodel.Status, boost
local = false
}
+ sensitive := *s.Sensitive
+ pinned := false // can't pin a boost
+ federated := *s.Federated
+ boostable := *s.Boostable
+ replyable := *s.Replyable
+ likeable := *s.Likeable
+
boostWrapperStatus := &gtsmodel.Status{
ID: boostWrapperStatusID,
URI: boostWrapperStatusURI,
@@ -46,7 +56,7 @@ func (c *converter) StatusToBoost(ctx context.Context, s *gtsmodel.Status, boost
// the boosted status is not created now, but the boost certainly is
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
- Local: local,
+ Local: &local,
AccountID: boostingAccount.ID,
AccountURI: boostingAccount.URI,
@@ -64,16 +74,17 @@ func (c *converter) StatusToBoost(ctx context.Context, s *gtsmodel.Status, boost
Content: s.Content,
ContentWarning: s.ContentWarning,
ActivityStreamsType: s.ActivityStreamsType,
- Sensitive: s.Sensitive,
+ Sensitive: &sensitive,
Language: s.Language,
Text: s.Text,
BoostOfID: s.ID,
BoostOfAccountID: s.AccountID,
Visibility: s.Visibility,
- Federated: s.Federated,
- Boostable: s.Boostable,
- Replyable: s.Replyable,
- Likeable: s.Likeable,
+ Pinned: &pinned,
+ Federated: &federated,
+ Boostable: &boostable,
+ Replyable: &replyable,
+ Likeable: &likeable,
// attach these here for convenience -- the boosted status/account won't go in the DB
// but they're needed in the processor and for the frontend. Since we have them, we can
diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go
index bb611dd8f..43036c352 100644
--- a/internal/typeutils/internaltoas.go
+++ b/internal/typeutils/internaltoas.go
@@ -145,13 +145,13 @@ func (c *converter) AccountToAS(ctx context.Context, a *gtsmodel.Account) (vocab
// manuallyApprovesFollowers
// Will be shown as a locked account.
manuallyApprovesFollowersProp := streams.NewActivityStreamsManuallyApprovesFollowersProperty()
- manuallyApprovesFollowersProp.Set(a.Locked)
+ manuallyApprovesFollowersProp.Set(*a.Locked)
person.SetActivityStreamsManuallyApprovesFollowers(manuallyApprovesFollowersProp)
// discoverable
// Will be shown in the profile directory.
discoverableProp := streams.NewTootDiscoverableProperty()
- discoverableProp.Set(a.Discoverable)
+ discoverableProp.Set(*a.Discoverable)
person.SetTootDiscoverable(discoverableProp)
// devices
@@ -539,7 +539,7 @@ func (c *converter) StatusToAS(ctx context.Context, s *gtsmodel.Status) (vocab.A
// sensitive
sensitiveProp := streams.NewActivityStreamsSensitiveProperty()
- sensitiveProp.AppendXMLSchemaBoolean(s.Sensitive)
+ sensitiveProp.AppendXMLSchemaBoolean(*s.Sensitive)
status.SetActivityStreamsSensitive(sensitiveProp)
return status, nil
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index da124ce6c..7da54f979 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -60,7 +60,7 @@ func (c *converter) AccountToAPIAccountSensitive(ctx context.Context, a *gtsmode
apiAccount.Source = &model.Source{
Privacy: c.VisToAPIVis(ctx, a.Privacy),
- Sensitive: a.Sensitive,
+ Sensitive: *a.Sensitive,
Language: a.Language,
StatusFormat: statusFormat,
Note: a.NoteRaw,
@@ -172,8 +172,8 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
Username: a.Username,
Acct: acct,
DisplayName: a.DisplayName,
- Locked: a.Locked,
- Bot: a.Bot,
+ Locked: *a.Locked,
+ Bot: *a.Bot,
CreatedAt: util.FormatISO8601(a.CreatedAt),
Note: a.Note,
URL: a.URL,
@@ -213,7 +213,7 @@ func (c *converter) AccountToAPIAccountBlocked(ctx context.Context, a *gtsmodel.
Username: a.Username,
Acct: acct,
DisplayName: a.DisplayName,
- Bot: a.Bot,
+ Bot: *a.Bot,
CreatedAt: util.FormatISO8601(a.CreatedAt),
URL: a.URL,
Suspended: suspended,
@@ -323,7 +323,7 @@ func (c *converter) EmojiToAPIEmoji(ctx context.Context, e *gtsmodel.Emoji) (mod
Shortcode: e.Shortcode,
URL: e.ImageURL,
StaticURL: e.ImageStaticURL,
- VisibleInPicker: e.VisibleInPicker,
+ VisibleInPicker: *e.VisibleInPicker,
Category: e.CategoryID,
}, nil
}
@@ -539,7 +539,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
CreatedAt: util.FormatISO8601(s.CreatedAt),
InReplyToID: s.InReplyToID,
InReplyToAccountID: s.InReplyToAccountID,
- Sensitive: s.Sensitive,
+ Sensitive: *s.Sensitive,
SpoilerText: s.ContentWarning,
Visibility: c.VisToAPIVis(ctx, s.Visibility),
Language: s.Language,
@@ -552,7 +552,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
Bookmarked: statusInteractions.Bookmarked,
Muted: statusInteractions.Muted,
Reblogged: statusInteractions.Reblogged,
- Pinned: s.Pinned,
+ Pinned: *s.Pinned,
Content: s.Content,
Application: apiApplication,
Account: apiAuthorAccount,
@@ -762,7 +762,7 @@ func (c *converter) DomainBlockToAPIDomainBlock(ctx context.Context, b *gtsmodel
// if we're exporting a domain block, return it with minimal information attached
if !export {
domainBlock.ID = b.ID
- domainBlock.Obfuscate = b.Obfuscate
+ domainBlock.Obfuscate = *b.Obfuscate
domainBlock.PrivateComment = b.PrivateComment
domainBlock.SubscriptionID = b.SubscriptionID
domainBlock.CreatedBy = b.CreatedByAccountID