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

[Server v3] Remove code duplication for each authenticated route #7119

Open
vxgmichel opened this issue Apr 19, 2024 · 0 comments · May be fixed by #7306
Open

[Server v3] Remove code duplication for each authenticated route #7119

vxgmichel opened this issue Apr 19, 2024 · 0 comments · May be fixed by #7306
Assignees
Labels
A-Server Area: Server application I-Postgresql Impact: Postgresql issue refactor Improve code, don't change behavior
Milestone

Comments

@vxgmichel
Copy link
Contributor

Those blocks are repeated for each authenticated route:

        match await self.organization._get(conn, organization_id):
            case OrganizationGetBadOutcome.ORGANIZATION_NOT_FOUND:
                return RealmShareStoreBadOutcome.ORGANIZATION_NOT_FOUND
            case Organization() as org:
                pass

        if org.is_expired:
            return RealmShareStoreBadOutcome.ORGANIZATION_EXPIRED

        match await self.user._check_device(conn, organization_id, author):
            case CheckDeviceBadOutcome.DEVICE_NOT_FOUND:
                return RealmShareStoreBadOutcome.AUTHOR_NOT_FOUND
            case CheckDeviceBadOutcome.USER_NOT_FOUND:
                return RealmShareStoreBadOutcome.AUTHOR_NOT_FOUND
            case CheckDeviceBadOutcome.USER_REVOKED:
                return RealmShareStoreBadOutcome.AUTHOR_REVOKED
            case (UserProfile(), DateTime()):
                pass

That's a lot of duplication that can be factorized away.

@vxgmichel vxgmichel changed the title [Sever v3] Remove code duplication for each authenticated route [Server v3] Remove code duplication for each authenticated route Apr 19, 2024
@mmmarcos mmmarcos added I-Postgresql Impact: Postgresql issue A-Server Area: Server application enhancement Improve functionality, potentially changing behavior refactor Improve code, don't change behavior and removed enhancement Improve functionality, potentially changing behavior labels Apr 22, 2024
@mmmarcos mmmarcos self-assigned this Apr 25, 2024
@mmmarcos mmmarcos added this to the v3.0 milestone Apr 25, 2024
@mmmarcos mmmarcos linked a pull request May 15, 2024 that will close this issue
@mmmarcos mmmarcos modified the milestones: v3.0, v3.1 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Server Area: Server application I-Postgresql Impact: Postgresql issue refactor Improve code, don't change behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants