Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mastodon] add "instance_remote" field #3119

Merged
merged 1 commit into from
Nov 2, 2022
Merged

Conversation

allendema
Copy link
Contributor

@allendema allendema commented Oct 29, 2022

Example usage:

If the url is mastodon:https://social.linux.pizza/@[email protected]
the "remote_instance" will be "botsin.space".

"directory": ["mastodon", "{instance_remote|instance}", "{account[username]!l}"]

Comment on lines 47 to 50
if "@" in status["account"]["acct"]:
status["remote_instance"] = status["account"]["acct"].split('@')[1]
else:
status["remote_instance"] = None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if "@" in status["account"]["acct"]:
status["remote_instance"] = status["account"]["acct"].split('@')[1]
else:
status["remote_instance"] = None
acct = status["account"]["acct"]
status["remote_instance"] = \
acct.rpartition("@")[2] if "@" in acct else None
  • Accessing status["account"]["acct"] multiple times is slower than storing it in a local variable
  • I prefer (r)partition over split. It's usually even faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you suggestions. I had messed up flake8 with GH GUI.

@mikf
Copy link
Owner

mikf commented Oct 29, 2022

Do you think it'd be better to call this field instance_remote instead?
(better when metadata field names get listed alphabetically)

And what about only defining it when a post/status is from a remote instance?

@allendema
Copy link
Contributor Author

call this field instance_remote instead?

That is also fine.

And what about only defining it when a post/status is from a remote instance?

Would that hide the field from the -K option if its a local instance - so nobody will use this field?

@mikf
Copy link
Owner

mikf commented Oct 29, 2022

Would that hide the field from the -K option if its a local instance - so nobody will use this field?

It would ... OK, lets forget about that idea then.
I'd still like to call it instance_remote.

Example Usage:
If the url is ```"mastodon:https://mastodon.example.org/@[email protected] the "remote_instance" will be "botsin.space"
...
"directory": ["mastodon", "{remote_instance|instance}", "{account[username]!l}"]
...
@allendema allendema changed the title [mastodon] add "remote_instance" field [mastodon] add "instance_remote" field Oct 29, 2022
@mikf mikf merged commit 9fc142d into mikf:master Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants