summaryrefslogtreecommitdiff
path: root/internal/typeutils
diff options
context:
space:
mode:
Diffstat (limited to 'internal/typeutils')
-rw-r--r--internal/typeutils/astointernal.go14
-rw-r--r--internal/typeutils/astointernal_test.go1
-rw-r--r--internal/typeutils/converter_test.go2
3 files changed, 16 insertions, 1 deletions
diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go
index 8a451adc8..fa2ae6a62 100644
--- a/internal/typeutils/astointernal.go
+++ b/internal/typeutils/astointernal.go
@@ -77,6 +77,18 @@ func (c *Converter) ASRepresentationToAccount(ctx context.Context, accountable a
return nil, gtserror.SetMalformed(err)
}
+ // Extract published time if possible.
+ //
+ // This denotes original creation time
+ // of the account on the remote instance.
+ //
+ // Not every implementation uses this property;
+ // so don't bother warning if we can't find it.
+ if pub := ap.GetPublished(accountable); !pub.IsZero() {
+ acct.CreatedAt = pub
+ acct.UpdatedAt = pub
+ }
+
// Extract a preferred name (display name), fallback to username.
if displayName := ap.ExtractName(accountable); displayName != "" {
acct.DisplayName = displayName
@@ -300,7 +312,7 @@ func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
// status.Published
//
- // Extract published time for the boost,
+ // Extract published time for the status,
// zero-time will fall back to db defaults.
if pub := ap.GetPublished(statusable); !pub.IsZero() {
status.CreatedAt = pub
diff --git a/internal/typeutils/astointernal_test.go b/internal/typeutils/astointernal_test.go
index 84fdfd064..627f9cac7 100644
--- a/internal/typeutils/astointernal_test.go
+++ b/internal/typeutils/astointernal_test.go
@@ -146,6 +146,7 @@ func (suite *ASToInternalTestSuite) TestParseGargron() {
acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, "")
suite.NoError(err)
suite.Equal("https://mastodon.social/inbox", *acct.SharedInboxURI)
+ suite.Equal(int64(1458086400), acct.CreatedAt.Unix())
}
func (suite *ASToInternalTestSuite) TestParseReplyWithMention() {
diff --git a/internal/typeutils/converter_test.go b/internal/typeutils/converter_test.go
index 8a0dcd0fd..38376c87a 100644
--- a/internal/typeutils/converter_test.go
+++ b/internal/typeutils/converter_test.go
@@ -279,6 +279,8 @@ const (
"url": "https://mastodon.social/@Gargron",
"manuallyApprovesFollowers": false,
"discoverable": true,
+ "indexable": true,
+ "published": "2016-03-16T00:00:00Z",
"devices": "https://mastodon.social/users/Gargron/collections/devices",
"alsoKnownAs": [
"https://tooting.ai/users/Gargron"