enbas/internal/model/account_relationship.go
Dan Anglin 1a95384ba0
feat: followers and following others
This commit adds the ability to follow and unfollow (remote)
accounts and to display a list of followers and followees for
a specified account.

Changes:

- Added a command to follow an account.
- Added a command to unfollow an account.
- When displaying an account you can optionally view the relationship
  between that account and yourself.
- Added a command to view accounts that are following a specified
  account.
- Added a command to view accounts that are followed by a specified
  account.
2024-05-20 17:31:50 +01:00

70 lines
2 KiB
Go

package model
import (
"fmt"
"codeflow.dananglin.me.uk/apollo/enbas/internal/utilities"
)
type AccountRelationship struct {
ID string `json:"id"`
PrivateNote string `json:"note"`
BlockedBy bool `json:"blocked_by"`
Blocking bool `json:"blocking"`
DomainBlocking bool `json:"domain_blocking"`
Endorsed bool `json:"endorsed"`
FollowedBy bool `json:"followed_by"`
Following bool `json:"following"`
Muting bool `json:"muting"`
MutingNotifications bool `json:"muting_notifications"`
Notifying bool `json:"notifying"`
FollowRequested bool `json:"requested"`
FollowRequestedBy bool `json:"requested_by"`
ShowingReblogs bool `json:"showing_reblogs"`
}
func (a AccountRelationship) String() string {
format := `
%s
%s: %t
%s: %t
%s: %t
%s: %t
%s: %t
%s: %t
%s: %t
%s: %t
%s: %t
%s: %t
%s: %t`
privateNoteFormat := `
%s
%s`
output := fmt.Sprintf(
format,
utilities.HeaderFormat("YOUR RELATIONSHIP WITH THIS ACCOUNT:"),
utilities.FieldFormat("Following"), a.Following,
utilities.FieldFormat("Is following you"), a.FollowedBy,
utilities.FieldFormat("A follow request was sent and is pending"), a.FollowRequested,
utilities.FieldFormat("Received a pending follow request"), a.FollowRequestedBy,
utilities.FieldFormat("Endorsed"), a.Endorsed,
utilities.FieldFormat("Showing Reposts (boosts)"), a.ShowingReblogs,
utilities.FieldFormat("Muted"), a.Muting,
utilities.FieldFormat("Notifications muted"), a.MutingNotifications,
utilities.FieldFormat("Blocking"), a.Blocking,
utilities.FieldFormat("Is blocking you"), a.BlockedBy,
utilities.FieldFormat("Blocking account's domain"), a.DomainBlocking,
)
if a.PrivateNote != "" {
output += fmt.Sprintf(
privateNoteFormat,
utilities.HeaderFormat("YOUR PRIVATE NOTE ABOUT THIS ACCOUNT:"),
utilities.WrapLines(a.PrivateNote, "\n ", 80),
)
}
return output
}