2017-04-15 15:12:07 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-17 04:10:29 +02:00
|
|
|
"context"
|
2017-04-15 15:12:07 +02:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/fatih/color"
|
|
|
|
"github.com/mattn/go-mastodon"
|
2022-11-27 05:24:42 +01:00
|
|
|
"github.com/urfave/cli/v2"
|
2017-04-15 15:12:07 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func cmdNotification(c *cli.Context) error {
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
2017-05-06 16:49:46 +02:00
|
|
|
notifications, err := client.GetNotifications(context.Background(), nil)
|
2017-04-15 15:12:07 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, n := range notifications {
|
|
|
|
if n.Status != nil {
|
|
|
|
color.Set(color.FgHiRed)
|
2017-04-19 13:52:14 +02:00
|
|
|
fmt.Fprint(c.App.Writer, n.Account.Acct)
|
2017-04-15 15:12:07 +02:00
|
|
|
color.Set(color.Reset)
|
2017-04-16 15:50:09 +02:00
|
|
|
fmt.Fprintln(c.App.Writer, " "+n.Type)
|
2017-04-15 15:12:07 +02:00
|
|
|
s := n.Status
|
2017-04-16 15:50:09 +02:00
|
|
|
fmt.Fprintln(c.App.Writer, textContent(s.Content))
|
2017-04-15 15:12:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|