From 2e3094a4b6ccc1fc63417bf86660e0e40d0ec7d4 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 18 Jan 2021 17:25:21 -0500 Subject: [PATCH] i think this will work with mastodon import and boosts --- import.go | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/import.go b/import.go index 60a16da..2d8b6ac 100644 --- a/import.go +++ b/import.go @@ -39,6 +39,32 @@ func importMain(username, flavor, source string) { } } +type TootObject struct { + Summary string + Content string + InReplyTo string + Conversation string + Published time.Time + Tag []struct { + Type string + Name string + } + Attachment []struct { + Type string + MediaType string + Url string + Name string + } +} + +type PlainTootObject TootObject + +func (obj *TootObject) UnmarshalJSON(b []byte) error { + p := (*PlainTootObject)(obj) + json.Unmarshal(b, p) + return nil +} + func importMastodon(username, source string) { user, err := butwhatabout(username) if err != nil { @@ -49,23 +75,7 @@ func importMastodon(username, source string) { Type string To []string Cc []string - Object struct { - Summary string - Content string - InReplyTo string - Conversation string - Published time.Time - Tag []struct { - Type string - Name string - } - Attachment []struct { - Type string - MediaType string - Url string - Name string - } - } + Object TootObject } var outbox struct { OrderedItems []Toot @@ -94,6 +104,9 @@ func importMastodon(username, source string) { re_tootid := regexp.MustCompile("[^/]+$") for _, item := range outbox.OrderedItems { toot := item + if toot.Type != "Create" { + continue + } tootid := re_tootid.FindString(toot.Id) xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, tootid) if havetoot(xid) {