diff --git a/cmd/mstdn/cmd_followers.go b/cmd/mstdn/cmd_followers.go index 20fc7f2..62ca366 100644 --- a/cmd/mstdn/cmd_followers.go +++ b/cmd/mstdn/cmd_followers.go @@ -19,7 +19,7 @@ func cmdFollowers(c *cli.Context) error { return err } for _, follower := range followers { - fmt.Fprintf(c.App.Writer, "%v,%v\n", follower.ID, follower.Username) + fmt.Fprintf(c.App.Writer, "%v,%v\n", follower.ID, follower.Acct) } return nil } diff --git a/cmd/mstdn/cmd_notification.go b/cmd/mstdn/cmd_notification.go index 6936751..6d4192c 100644 --- a/cmd/mstdn/cmd_notification.go +++ b/cmd/mstdn/cmd_notification.go @@ -18,7 +18,7 @@ func cmdNotification(c *cli.Context) error { for _, n := range notifications { if n.Status != nil { color.Set(color.FgHiRed) - fmt.Fprint(c.App.Writer, n.Account.Username) + fmt.Fprint(c.App.Writer, n.Account.Acct) color.Set(color.Reset) fmt.Fprintln(c.App.Writer, " "+n.Type) s := n.Status diff --git a/cmd/mstdn/cmd_stream.go b/cmd/mstdn/cmd_stream.go index 0e645c2..1c89acb 100644 --- a/cmd/mstdn/cmd_stream.go +++ b/cmd/mstdn/cmd_stream.go @@ -17,6 +17,7 @@ import ( type SimpleJSON struct { ID int64 `json:"id"` Username string `json:"username"` + Acct string `json:"acct"` Avatar string `json:"avatar"` Content string `json:"content"` } @@ -61,6 +62,7 @@ func cmdStream(c *cli.Context) error { json.NewEncoder(c.App.Writer).Encode(&SimpleJSON{ ID: t.Status.ID, Username: t.Status.Account.Username, + Acct: t.Status.Account.Acct, Avatar: t.Status.Account.AvatarStatic, Content: textContent(t.Status.Content), }) diff --git a/cmd/mstdn/cmd_timeline.go b/cmd/mstdn/cmd_timeline.go index 26f2142..99689f0 100644 --- a/cmd/mstdn/cmd_timeline.go +++ b/cmd/mstdn/cmd_timeline.go @@ -3,24 +3,49 @@ package main import ( "context" "fmt" + "net/url" + "strings" "github.com/fatih/color" "github.com/mattn/go-mastodon" "github.com/urfave/cli" ) +func acct(acct, host string) string { + if !strings.Contains(acct, "@") { + acct += "@" + host + } + return acct +} + func cmdTimeline(c *cli.Context) error { client := c.App.Metadata["client"].(*mastodon.Client) + config := c.App.Metadata["config"].(*mastodon.Config) timeline, err := client.GetTimelineHome(context.Background()) if err != nil { return err } + u, err := url.Parse(config.Server) + if err != nil { + return err + } for i := len(timeline) - 1; i >= 0; i-- { t := timeline[i] - color.Set(color.FgHiRed) - fmt.Fprintln(c.App.Writer, t.Account.Username) - color.Set(color.Reset) - fmt.Fprintln(c.App.Writer, textContent(t.Content)) + if t.Reblog != nil { + color.Set(color.FgHiRed) + fmt.Fprint(c.App.Writer, acct(t.Account.Acct, u.Host)) + color.Set(color.Reset) + fmt.Fprint(c.App.Writer, " rebloged ") + color.Set(color.FgHiBlue) + fmt.Fprintln(c.App.Writer, acct(t.Reblog.Account.Acct, u.Host)) + fmt.Fprintln(c.App.Writer, textContent(t.Reblog.Content)) + color.Set(color.Reset) + } else { + color.Set(color.FgHiRed) + fmt.Fprintln(c.App.Writer, acct(t.Account.Acct, u.Host)) + color.Set(color.Reset) + fmt.Fprintln(c.App.Writer, textContent(t.Content)) + } } return nil }