fix subscription check

This commit is contained in:
Andriy Cherniy 2024-01-05 20:29:04 +02:00
parent d3f51c73b5
commit 4a63f5e45d

23
main.go
View file

@ -106,6 +106,19 @@ func main() {
log.Fatal(err)
}
var subscribers []*mastodon.Account
var pg mastodon.Pagination
for {
fs, err := masto_client.GetAccountFollowers(context.Background(), masto_user.ID, &pg)
if err != nil {
log.Fatal(err)
}
subscribers = append(subscribers, fs...)
if pg.MaxID == "" {
break
}
}
// log.Println(my_account)
matrix_client, err := mautrix.NewClient(os.Getenv("MATRIX_HOMESERVER"), m_id.UserID(os.Getenv("MATRIX_USERNAME")), os.Getenv("MATRIX_ACCESS_TOKEN"))
@ -225,6 +238,8 @@ notif_loop:
}
}
subscribers = append(subscribers, &notif.Account)
masto_client.PostStatus(ctx, &mastodon.Toot{
Status: fmt.Sprintf("Вітаємо у нашій спільноті! @%s", notif.Account.Acct),
Visibility: mastodon.VisibilityUnlisted,
@ -236,13 +251,7 @@ notif_loop:
}
if notif.Type == "mention" && notif.Status.InReplyToID == nil && notif.Status.InReplyToAccountID == nil {
log.Debugf(`post passed reply check (%v)
raw data: %v`, notif.Status.ID, notif.Status)
subscribers, err := masto_client.GetAccountFollowers(ctx, masto_user.ID, &mastodon.Pagination{Limit: 10000})
if err != nil {
log.Error(err)
continue
}
log.Debugf(`post passed reply check (%v)`, notif.Status.ID)
ok := false