diff --git a/internal/executor/show.go b/internal/executor/show.go index 553f712..16eec54 100644 --- a/internal/executor/show.go +++ b/internal/executor/show.go @@ -338,7 +338,7 @@ func (s *ShowExecutor) showNotifications(gts *client.Client) error { } for i := range notifications { - fmt.Printf("\nNotification ID: %s\n%s", notifications[i].ID, notifications[i].Type) + utilities.Display(notifications[i], *s.topLevelFlags.NoColor) } return nil diff --git a/internal/model/notification.go b/internal/model/notification.go index 089edd6..e532dc2 100644 --- a/internal/model/notification.go +++ b/internal/model/notification.go @@ -8,6 +8,8 @@ import ( "encoding/json" "fmt" "time" + + "codeflow.dananglin.me.uk/apollo/enbas/internal/utilities" ) type NotificationType int @@ -33,20 +35,20 @@ const ( notificationStatus = "status" ) -func (n NotificationType) String() string { +func (n NotificationType) MessageFormat() string { mapped := map[NotificationType]string{ - NotificationTypeFollow: "Someone followed you", - NotificationTypeFollowRequest: "Someone requested to follow you", - NotificationTypeMention: "Someone mentioned you in their status", - NotificationTypeReblog: "Someone reposted one of your statuses", - NotificationTypeFavourite: "Someone liked one of your statuses", - NotificationTypePoll: "A poll you have participated in has ended", - NotificationTypeStatus: "Someone you enabled notifications for has posted a status", + NotificationTypeFollow: "%s followed you", + NotificationTypeFollowRequest: "%s has requested to follow you", + NotificationTypeMention: "%s has mentioned you in this status", + NotificationTypeReblog: "%s reposted this status from you", + NotificationTypeFavourite: "%s liked this status from you", + NotificationTypePoll: "A poll from %s that you have voted in has ended", + NotificationTypeStatus: "%s has posted this status", } output, ok := mapped[n] if !ok { - return "You have received an unknown notification" + return "You have received a notification of an unknown type" } return output @@ -101,3 +103,7 @@ type Notification struct { Status *Status `json:"status"` Type NotificationType `json:"type"` } + +func (n Notification) Display(noColor bool) string { + return fmt.Sprintf(n.Type.MessageFormat(), utilities.DisplayNameFormat(noColor, n.Account.DisplayName) + " (@" + n.Account.Acct + ")") +}