i think this will work with mastodon import and boosts

This commit is contained in:
Ted Unangst 2021-01-18 17:25:21 -05:00
parent 758ad54a04
commit 2e3094a4b6

View file

@ -39,17 +39,7 @@ func importMain(username, flavor, source string) {
} }
} }
func importMastodon(username, source string) { type TootObject struct {
user, err := butwhatabout(username)
if err != nil {
log.Fatal(err)
}
type Toot struct {
Id string
Type string
To []string
Cc []string
Object struct {
Summary string Summary string
Content string Content string
InReplyTo string InReplyTo string
@ -66,6 +56,26 @@ func importMastodon(username, source string) {
Name 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 {
log.Fatal(err)
}
type Toot struct {
Id string
Type string
To []string
Cc []string
Object TootObject
} }
var outbox struct { var outbox struct {
OrderedItems []Toot OrderedItems []Toot
@ -94,6 +104,9 @@ func importMastodon(username, source string) {
re_tootid := regexp.MustCompile("[^/]+$") re_tootid := regexp.MustCompile("[^/]+$")
for _, item := range outbox.OrderedItems { for _, item := range outbox.OrderedItems {
toot := item toot := item
if toot.Type != "Create" {
continue
}
tootid := re_tootid.FindString(toot.Id) tootid := re_tootid.FindString(toot.Id)
xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, tootid) xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, tootid)
if havetoot(xid) { if havetoot(xid) {