-
Notifications
You must be signed in to change notification settings - Fork 14
Refactor notification jobs to shared background service #1806
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { Args, ResolveField, Resolver } from '@nestjs/graphql'; | ||
|
|
||
| import { AuthAction, Resource } from '@unraid/shared/graphql.model.js'; | ||
| import { PrefixedID } from '@unraid/shared/prefixed-id-scalar.js'; | ||
| import { UsePermissions } from '@unraid/shared/use-permissions.directive.js'; | ||
|
|
||
| import { AppError } from '@app/core/errors/app-error.js'; | ||
| import { | ||
| NotificationImportance, | ||
| NotificationJob, | ||
| NotificationJobState, | ||
| NotificationMutations, | ||
| NotificationOverview, | ||
| NotificationType, | ||
| } from '@app/unraid-api/graph/resolvers/notifications/notifications.model.js'; | ||
|
Comment on lines
+8
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix NotificationMutations import to resolve CI failure CI error shows Update the imports to pull -import {
- NotificationImportance,
- NotificationJob,
- NotificationJobState,
- NotificationMutations,
- NotificationOverview,
- NotificationType,
-} from '@app/unraid-api/graph/resolvers/notifications/notifications.model.js';
+import {
+ NotificationImportance,
+ NotificationJob,
+ NotificationJobState,
+ NotificationOverview,
+ NotificationType,
+} from '@app/unraid-api/graph/resolvers/notifications/notifications.model.js';
+import { NotificationMutations } from '@app/unraid-api/graph/resolvers/mutation/mutation.model.js';🧰 Tools🪛 GitHub Actions: CI - Main (API)[error] 12-12: "NotificationMutations" is not exported by "src/unraid-api/graph/resolvers/notifications/notifications.model.ts", imported by "src/unraid-api/graph/resolvers/notifications/notifications.mutations.resolver.ts". 🤖 Prompt for AI Agents |
||
| import { NotificationsService } from '@app/unraid-api/graph/resolvers/notifications/notifications.service.js'; | ||
|
|
||
| @Resolver(() => NotificationMutations) | ||
| export class NotificationMutationsResolver { | ||
| constructor(private readonly notificationsService: NotificationsService) {} | ||
|
|
||
| @ResolveField(() => NotificationOverview) | ||
| @UsePermissions({ | ||
| action: AuthAction.DELETE_ANY, | ||
| resource: Resource.NOTIFICATIONS, | ||
| }) | ||
| public async delete( | ||
| @Args('id', { type: () => PrefixedID }) id: string, | ||
| @Args('type', { type: () => NotificationType }) type: NotificationType | ||
| ): Promise<NotificationOverview> { | ||
| const { overview } = await this.notificationsService.deleteNotification({ id, type }); | ||
| return overview; | ||
| } | ||
|
|
||
| @ResolveField(() => NotificationJob) | ||
| @UsePermissions({ | ||
| action: AuthAction.DELETE_ANY, | ||
| resource: Resource.NOTIFICATIONS, | ||
| }) | ||
| public async startArchiveAll( | ||
| @Args('importance', { type: () => NotificationImportance, nullable: true }) | ||
| importance?: NotificationImportance | ||
| ): Promise<NotificationJob> { | ||
| return this.notificationsService.startArchiveAllJob(importance); | ||
| } | ||
|
|
||
| @ResolveField(() => NotificationJob) | ||
| @UsePermissions({ | ||
| action: AuthAction.DELETE_ANY, | ||
| resource: Resource.NOTIFICATIONS, | ||
| }) | ||
| public async startDeleteAll( | ||
| @Args('type', { type: () => NotificationType, nullable: true }) type?: NotificationType | ||
| ): Promise<NotificationJob> { | ||
| const job = await this.notificationsService.startDeleteAllJob(type); | ||
| if (job.state === NotificationJobState.FAILED) { | ||
| throw new AppError(job.error ?? 'Failed to delete notifications', 500); | ||
| } | ||
| return job; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.