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

Upgrade Editorial permissions library to latest version #1142

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

rtyley
Copy link
Member

@rtyley rtyley commented Jan 31, 2024

This upgrades the Media Atom Maker to use the latest version of the client for the Guardian's Editorial Permissions service - we need the latest version of the client to support the upgrade to Scala 2.13 in #1140

Permissions library versions

As you can see, the permissions client has moved repositories, to the main permissions repo - this happened in July 2018 with PR https://github.com/guardian/permissions/pull/103. This PR is also important because it removed use of Future from the permissions client API - as Michael Barton explained, permission lookups should be mostly instantaneous because they now come from an in-memory cache.

The removal of Future means that this PR, upgrading Media Atom Maker, needs to remove several for-comprehensions/map-statements. The diff on these can look quite big, but they look smaller if whitespace
changes are ignored. I've taken the opportunity to do small refactors to improve code clarity and remove repetition.

Permission to modify Privacy Status of a published Media Atom

In particular, the code around modifying Privacy Status of a Media Atom had to be changed because it involved removing Future, but I also included refactoring to make the code clearer. When reviewing this, you may want to look at the original PRs that introduced this logic:

@rtyley rtyley force-pushed the upgrade-permissions-library branch from 4fdc945 to b08dcb3 Compare January 31, 2024 17:17
@rtyley rtyley changed the title Upgrade permissions library Upgrade Editorial permissions library to latest version Feb 1, 2024
@rtyley rtyley force-pushed the upgrade-permissions-library branch 5 times, most recently from b49e3b0 to 8316075 Compare February 1, 2024 12:11
@rtyley rtyley marked this pull request as ready for review February 1, 2024 12:29
@rtyley rtyley requested a review from a team as a code owner February 1, 2024 12:29
@rtyley rtyley force-pushed the upgrade-permissions-library branch from 8316075 to 9abd55e Compare February 1, 2024 14:02
rtyley added a commit that referenced this pull request Feb 2, 2024
Small conflict between these two PRs on how to create a
MediaAtomMakerPermissionsProvider:

* #1142
* #1143
@rtyley rtyley mentioned this pull request Feb 2, 2024
@rtyley rtyley force-pushed the upgrade-permissions-library branch 2 times, most recently from 9cd7d90 to a682f9b Compare February 7, 2024 16:37
rtyley added a commit that referenced this pull request Feb 7, 2024
Copy link
Contributor

@rhystmills rhystmills left a comment

Choose a reason for hiding this comment

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

Code looking good, and tested the following in code with the upload s3 permission:

  • Permission not present
  • Permission present
  • Changing permission (updating after 1 minute)
    All working as intended 👍

This upgrades the Media Atom Maker to use the latest version of
the client for the Guardian's Editorial Permissions service - we
need the latest version of the client to support the upgrade to
Scala 2.13 in #1140

* Before: https://github.com/guardian/editorial-permissions-client/tree/v0.8 - supporting Scala 2.11 & 2.12
* After: https://github.com/guardian/permissions/tree/v2.15/client - supporting Scala 2.12 & 2.13

As you can see, the permissions client has moved repositories, to the
main `permissions` repo - this happened in July 2018 with PR
guardian/permissions#103. This PR is also
important because it removed use of `Future` from the permissions
client API - as Michael Barton explained, permission lookups should
be mostly instantaneous because they now come from an in-memory cache.

The removal of `Future` means that this commit, upgrading permissions in
Media Atom Maker, needs to remove several for-comprehensions/map-statements.
The diff on these can look quite big, but they look smaller if whitespace
changes are ignored. I have taken the opportunity to do small refactors to
improve code clarity and remove repetition.

In particular, the code around modifying Privacy Status of a Media Atom
_had_ to be changed because it involved removing `Future`, but I also
included refactoring to make the code clearer. When reviewing this,
you may want to look at the original PRs that introduced this logic:

* #607 - introduced
  the concept of each of our YouTube channels having a different set of
  available PrivacyStatus (Private, Unlisted, Public) values.
* #694 - you can always
  upload as Public unless the channel is in the youtube.channels.unlisted
  config, in which case you need permission. This means we can give general
  users the ability to upload as Public on the culture channel and grant
  specific people access to make a public video on the main channel.
* #789 - public video
  should *stay* public when a metadata change is made by someone who
  does not have permission to *make* a video public on that channel.
* #791 - code shouldn't
  fail if the atom has not been published yet!
@rtyley rtyley force-pushed the upgrade-permissions-library branch from a682f9b to a0b063b Compare February 8, 2024 10:45
@rtyley rtyley merged commit aee3905 into main Feb 8, 2024
1 check passed
@rtyley rtyley deleted the upgrade-permissions-library branch February 8, 2024 10:57
@prout-bot
Copy link

Seen on PROD (merged by @rtyley 6 minutes and 26 seconds ago) Please check your changes!

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.

3 participants