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(). log.Info().
Str("toots", tootList.String()). Str("hostname", i.hostname).
Msgf("toots") 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") panic("unimplemented")
} }

View File

@ -95,65 +95,24 @@ func (atl *apTootList) String() string {
type apTootList []json.RawMessage type apTootList []json.RawMessage
/* type tootFromAPI struct {
type parsedToot struct {
Account struct { Account struct {
Acct string `json:"acct"` Acct string `json:"acct"`
Avatar string `json:"avatar"` ID string `json:"id"`
AvatarStatic string `json:"avatar_static"` URL string `json:"url"`
Bot bool `json:"bot"` Username string `json:"username"`
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"` } `json:"account"`
Application struct { Content string `json:"content"`
Name string `json:"name"` CreatedAt time.Time `json:"created_at"`
Website interface{} `json:"website"` ID string `json:"id"`
} `json:"application"` InReplyToAccountID string `json:"in_reply_to_account_id"`
Bookmarked bool `json:"bookmarked"` InReplyToID string `json:"in_reply_to_id"`
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 { Mentions []struct {
Acct string `json:"acct"` Acct string `json:"acct"`
ID string `json:"id"` ID string `json:"id"`
URL string `json:"url"` URL string `json:"url"`
Username string `json:"username"` Username string `json:"username"`
} `json:"mentions"` } `json:"mentions"`
Muted bool `json:"muted"` URI string `json:"uri"`
Pinned bool `json:"pinned"` URL string `json:"url"`
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 package feta
import "encoding/json"
type toot struct { 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 := new(toot)
t.original = input
t.parsed = new(tootFromAPI)
err = json.Unmarshal(*input, t.parsed)
if err != nil {
t.parsed = nil
}
return t return t
} }
func (t *toot) identityHashInput() string {
// id + datestamp + acct + content
}
func (t *toot) hash() tootHash {
}