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

Add ability to filter followed accounts' posts by language #19095

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Aug 29, 2022

Similar to how you can choose to be notified of an account's new posts, or hide reblogs from them, you can choose the languages that appear on your home feed, for example when following a multi-lingual account, you can make it so only the language you understand lands on your home feed.

image

REST API changes

  • New languages param on POST /api/v1/accounts/:id/follow
  • New languages attribute on Relationship entity

Other

  • CSV export and import of following lists now transfers the "notify on new posts" and languages preferences

This project was funded through the NGI0 Discovery Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825322.

@Gargron Gargron added the NLnet Funded by NLnet, see https://nlnet.nl/project/Mastodon/ label Aug 29, 2022
@Gargron Gargron force-pushed the feature-filter-follow-languages branch 3 times, most recently from f6ff504 to 5cf26f6 Compare August 30, 2022 20:00
@Gargron Gargron added the api REST API, Streaming API, Web Push API label Aug 30, 2022
@Gargron Gargron force-pushed the feature-filter-follow-languages branch 6 times, most recently from 8f6b5d4 to c2f9038 Compare August 31, 2022 20:06
@Gargron Gargron marked this pull request as ready for review August 31, 2022 20:12
@Gargron Gargron force-pushed the feature-filter-follow-languages branch 4 times, most recently from 21e6025 to 61ed41c Compare August 31, 2022 20:27
@Gargron Gargron requested a review from ykzts September 1, 2022 15:15
Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

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

I'm not completely sure about the “boosted” to “reblog” change, it's a breaking change for little gain (especially since “reblog” isn't currently used in the user interface).

I am very unsure about the way an account's languages is determined, it can easily cause you to miss languages, especially if new ones are added later on and/or if the account posts in a not very regular fashion (e.g. not the same amount of posts in each language, but with larger gaps between two posts in the same language).

Otherwise, the UI and code look fine to me.

(state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()),
state => state.get('statuses'),
], (statusIds, statuses) =>
new ImmutableSet(statusIds.map(statusId => statuses.get(statusId)).filter(status => !status.get('reblog')).map(status => status.get('language'))));
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to be a very reliable way of handling that… showing languages only for the posts that got loaded by the WebUI at that point… it may also slightly bias against languages, since those not selected by the user would not pop up into their Home TL and thus might not be known by the WebUI (if they aren't in the first page of the account's posts).

@Gargron Gargron removed the request for review from ykzts September 1, 2022 15:34
@Gargron
Copy link
Member Author

Gargron commented Sep 1, 2022

Okay, I can rename the CSV header back. I think the sourcing of the languages for selection is not perfect, but adequate. If you have e.g. an EU account, and they make a copy of the same post in every supported language, then those languages will be represented across the most recent posts. The alternatives are:

  • Display all known languages, similar to language selection dropdown in the compose form. The downside is that it's too much information, and those extra languages are pointless if the user does not post in them.
  • New API endpoint that returns an account's languages. But it would ultimately be the same type of calculation, just on the server side. E.g. when we calculate account_summaries, we look at the most recent posts too.
  • Load more posts into the client. I think this would be the most practical, but what is the reasonable cut-off point? This is why I went with the first page of results, as it is simplest.

@Gargron Gargron force-pushed the feature-filter-follow-languages branch from 61ed41c to 6aa0c88 Compare September 1, 2022 16:31
@Gargron
Copy link
Member Author

Gargron commented Sep 1, 2022

I renamed the CSV header back.

@ClearlyClaire
Copy link
Contributor

I guess it could work in most cases, but I'm really unsure how reliable that would be. Server-side on more posts seems more reliable but I don't know.

@Gargron
Copy link
Member Author

Gargron commented Sep 1, 2022

I think it's adequate for the initial implementation. If there is demand, we can add a server-side API.

@Gargron Gargron merged commit 50948b4 into main Sep 20, 2022
@Gargron Gargron deleted the feature-filter-follow-languages branch September 20, 2022 21:51
nametoolong pushed a commit to nametoolong/nuage that referenced this pull request Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api REST API, Streaming API, Web Push API NLnet Funded by NLnet, see https://nlnet.nl/project/Mastodon/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants