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

feat: Add configurable auto-approval #1190

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

augustuen
Copy link

Description

Add the ability to define "rules" for auto-approval, instead of the simple yes/no system from before.

Features:

  • Approve requests based on defined conditions
  • Modify users' requests according to the set rule before approving them
    • Ex: If a movie has the christmas tag, change the root folder to christmas_movies

Screenshot (if UI-related)

bilde
bilde

To-Dos

  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

@Fallenbagel
Copy link
Owner

Fallenbagel commented Dec 28, 2024

Suggestion: Move this to settings page as a tab. As this is 100% a setting

@gauthier-th
Copy link
Collaborator

It could be cool to have the same rule system as the override rules one: #945
With that we could improve/edit the "rules editor" at the same time for both rules system.

(But we could do it in another PR)

@augustuen augustuen force-pushed the feature-auto-approval-system branch from eb7cd47 to b2351d5 Compare December 29, 2024 19:38
@augustuen
Copy link
Author

augustuen commented Dec 29, 2024

Oh, I wasn't aware that existed! That looks really awesome. One thing I would've liked is the ability to send a notification without approving the request, but I don't see it as an absolute necessity.

With "same rule system", do you mean to use the same component for both? Or something in the backend?

@gauthier-th
Copy link
Collaborator

With "same rule system", do you mean to use the same component for both? Or something in the backend?

Probably more for the frontend, but if you can think of something clean for the backend it could be useful too (as long as the abstraction for the "rule system" doesn't make things more complicated)

@augustuen
Copy link
Author

augustuen commented Jan 2, 2025

Idk if this is genius or moronic (though I'm leaning towards the latter), but: The edit modal has basically a list of variable length of different kinds of conditions, which have different UIs (some have text boxes, others have multi-selects), and I'm trying to make adding new conditions later on as simple as possible, so I had the idea of putting the UI and the logic together in the same class.

Basically, it's this:

  [...]
  public boolean isSatisfiedBy(MediaRequest request){
    (...)
  }
  public Component = () => {
    return(
      <GenreSelector
        type='tv'
        defaultValue={value}
        isMulti
        onChange={...}
       />
    );
  }
}

Both isSatisfiedBy and Component are inherited from the base, with isSatisfiedBy being called by the API/backend to process an incoming request, and Component being used in the edit modal. This would in theory mean that the core code wouldn't have to be changed to accomodate new condition types (specifications) later on, since it would focus on AutoApprovalSpecificationBase, and leave it up to the specifications themselves to decide whether a request satisfies it, and to provide the UI components that they need.

IMO, this would consolidate it into a neat little package, but I can also see it being convoluted/messy/just generally bad practice to mix logic and UI in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants