This commit is contained in:
Jeffrey Paul 2019-12-14 09:03:38 -08:00
parent 135adaab04
commit 255554db97
3 changed files with 49 additions and 56 deletions

View File

@ -439,9 +439,15 @@ func (i *instance) fetchRecentToots() error {
}
log.Info().
Str("toots", tootList.String()).
Msgf("toots")
Str("hostname", i.hostname).
Int("tootCount", len(*tootList)).
Msgf("got and parsed toots")
i.registerSuccess()
i.Event("TOOTS_FETCHED")
for _, x := range *tootList {
fmt.Printf("%s\n", x.Content)
}
panic("unimplemented")
}

View File

@ -95,65 +95,24 @@ func (atl *apTootList) String() string {
type apTootList []json.RawMessage
/*
type parsedToot struct {
type tootFromAPI struct {
Account struct {
Acct string `json:"acct"`
Avatar string `json:"avatar"`
AvatarStatic string `json:"avatar_static"`
Bot bool `json:"bot"`
CreatedAt time.Time `json:"created_at"`
DisplayName string `json:"display_name"`
Fields []interface{} `json:"fields"`
FollowersCount int `json:"followers_count"`
FollowingCount int `json:"following_count"`
Header string `json:"header"`
HeaderStatic string `json:"header_static"`
ID string `json:"id"`
Locked bool `json:"locked"`
Note string `json:"note"`
Source struct {
Fields []interface{} `json:"fields"`
Note string `json:"note"`
Sensitive bool `json:"sensitive"`
} `json:"source"`
StatusesCount int `json:"statuses_count"`
URL string `json:"url"`
Username string `json:"username"`
} `json:"account"`
Application struct {
Name string `json:"name"`
Website interface{} `json:"website"`
} `json:"application"`
Bookmarked bool `json:"bookmarked"`
Card interface{} `json:"card"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
Favourited bool `json:"favourited"`
FavouritesCount int `json:"favourites_count"`
ID string `json:"id"`
InReplyToAccountID string `json:"in_reply_to_account_id"`
InReplyToID string `json:"in_reply_to_id"`
Language interface{} `json:"language"`
MediaAttachments []interface{} `json:"media_attachments"`
Mentions []struct {
Acct string `json:"acct"`
ID string `json:"id"`
URL string `json:"url"`
Username string `json:"username"`
} `json:"mentions"`
Muted bool `json:"muted"`
Pinned bool `json:"pinned"`
Poll interface{} `json:"poll"`
Reblog interface{} `json:"reblog"`
Reblogged bool `json:"reblogged"`
ReblogsCount int `json:"reblogs_count"`
RepliesCount int `json:"replies_count"`
Sensitive bool `json:"sensitive"`
SpoilerText string `json:"spoiler_text"`
Tags []interface{} `json:"tags"`
URI string `json:"uri"`
URL string `json:"url"`
Visibility string `json:"visibility"`
}
*/

30
toot.go
View File

@ -1,9 +1,37 @@
package feta
import "encoding/json"
type toot struct {
original *json.RawMessage
parsed *tootFromAPI
}
func newToot(input []byte) *toot {
func newToots(input []*json.RawMessage) []*toot {
l := make([]*toot, 0)
for x := range input {
t := newToot(x)
if t != nil {
l = append(l, t)
}
}
return l
}
func newToot(input *json.RawMessage) *toot {
t := new(toot)
t.original = input
t.parsed = new(tootFromAPI)
err = json.Unmarshal(*input, t.parsed)
if err != nil {
t.parsed = nil
}
return t
}
func (t *toot) identityHashInput() string {
// id + datestamp + acct + content
}
func (t *toot) hash() tootHash {
}