France-ioi / AlgoreaBackend

Backend for the new Algorea platform
MIT License
1 stars 2 forks source link

Fix item activity log services (display can_watch_answer correctly, show items visible to the team when 'as_team_id' is given). #1139

Closed zenovich closed 1 month ago

zenovich commented 1 month ago
  1. "can_watch_item_answer" added in #1027 didn't respect implicit permissions propagation from ancestor groups (see https://france-ioi.github.io/algorea-devdoc/items/access-rights/#propagation). So, when a user is a descendant of a group having can_watch_generated='answer' on an item, "can_watch_item_answer" was still false, it only respected direct permissions of the user. Here we fix this issue.
  2. "can_watch_item_answer" added in #1027 was displayed even if no 'watch_group_id' was given which doesn't make sense. This PR removes "can_watch_item_answer" from the responses if "watch_group_id" is not given.
  3. Here we rename "can_watch_item_answer" into "can_watch_answer" as there is no need to be so specific.
  4. The service used to return items visible to the user (not to the team) when "as_team_id" was given. This PR eliminates this issue as well.

Also, some useful functions making code more expressive and concise are being introduced here (see the new package "golang").

Fixes #1025 (really)

zenovich commented 1 month ago

fyi @GeoffreyHuck

zenovich commented 1 month ago

This PR doesn't affect the performance (checked)