muesli / beehive

A flexible event/agent & automation system with lots of bees 🐝
GNU Affero General Public License v3.0
6.25k stars 318 forks source link

Mastodon Triggers Actions inconsistencies #356

Closed Sakrecoer closed 3 years ago

Sakrecoer commented 3 years ago

Hi!

Thanks for an awesome tool!

I have been experimenting with the mastodon bees and actions and found an inconsistency and an unexpected behavior with {{.username}}. For reblog action, the definition states: "Mastodon handle of the user that re-blogged your toot" For follow action, the definition states: "Mastodon handle of the user which triggered the follow event"

1. Inconsistency

Expected result: As stated by the definitions of the action

Result: When the action is follow, {{.username}} prints the display name of the user following our account. When the action is reblog, {{.username}} prints the display name of our account.

2. Unexpected behavior (potentially wish-list)

Expected result {{.username}} prints the users handler: @user@example.com

Result {{.username}} prints the user's display name: 🦄 User's cool display name 🎉

While it is interesting to access the display name, it would be even nicer to get the handler @user@example.com because of how actionable it is compared to the display-name. This is what i expected the role of {{.user_id}} to be, but the latter seems to print the digits associated with the user (ex: 765432).

muesli commented 3 years ago

Thanks @Sakrecoer, I'll look into this!

corrantho commented 3 years ago

In beehive/mastodonbee/events.go we have the following code (line 177):

                {
                    Name:  "username",
                    Value: notif.Account.DisplayName,
                    Type:  "string",
                },

The event field username is indeed mapped with notif.Account.DisplayName. However, here is an extract of the information returned by the Mastodon GET ACCOUNT API (https://docs.joinmastodon.org/methods/accounts/#retrieve-information):

  "id": "23634",
  "username": "noiob",
  "acct": "noiob@awoo.space",
  "display_name": "shork",

My proposition is to implement the following change:

To be noted, and specified by the Mastodon API documentation, in the case of a local user, the fields acct and username have the same value.

Local user

  "id": "1",
  "username": "Gargron",
  "acct": "Gargron",
  "display_name": "Eugen",

Remote user

  "id": "23634",
  "username": "noiob",
  "acct": "noiob@awoo.space",
  "display_name": "shork",

@muesli If you agree with this change, I will introduce a PR this week.