Merge pull request #3568 from omnivore-app/feat/rules-delete-item-rule

Add a rule to delete items
This commit is contained in:
Jackson Harper
2024-02-26 12:13:40 +08:00
committed by GitHub
6 changed files with 12 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import { User } from './user'
export enum RuleActionType {
AddLabel = 'ADD_LABEL',
Archive = 'ARCHIVE',
Delete = 'DELETE',
MarkAsRead = 'MARK_AS_READ',
SendNotification = 'SEND_NOTIFICATION',
}

View File

@ -2215,6 +2215,7 @@ export type RuleActionInput = {
export enum RuleActionType {
AddLabel = 'ADD_LABEL',
Archive = 'ARCHIVE',
Delete = 'DELETE',
MarkAsRead = 'MARK_AS_READ',
SendNotification = 'SEND_NOTIFICATION'
}

View File

@ -1655,6 +1655,7 @@ input RuleActionInput {
enum RuleActionType {
ADD_LABEL
ARCHIVE
DELETE
MARK_AS_READ
SEND_NOTIFICATION
}

View File

@ -5,6 +5,7 @@ import { addLabelsToLibraryItem } from '../services/labels'
import {
SearchArgs,
searchLibraryItems,
softDeleteLibraryItem,
updateLibraryItem,
} from '../services/library_item'
import { findEnabledRules } from '../services/rules'
@ -38,6 +39,10 @@ const addLabels = async (obj: RuleActionObj) => {
)
}
const deleteLibraryItem = async (obj: RuleActionObj) => {
return softDeleteLibraryItem(obj.libraryItem.id, obj.userId)
}
const archivePage = async (obj: RuleActionObj) => {
return updateLibraryItem(
obj.libraryItem.id,
@ -76,6 +81,8 @@ const getRuleAction = (actionType: RuleActionType): RuleActionFunc => {
return addLabels
case RuleActionType.Archive:
return archivePage
case RuleActionType.Delete:
return deleteLibraryItem
case RuleActionType.MarkAsRead:
return markPageAsRead
case RuleActionType.SendNotification:

View File

@ -2135,6 +2135,7 @@ const schema = gql`
enum RuleActionType {
ADD_LABEL
ARCHIVE
DELETE
MARK_AS_READ
SEND_NOTIFICATION
}

View File

@ -11,6 +11,7 @@ export enum RuleActionType {
AddLabel = 'ADD_LABEL',
Archive = 'ARCHIVE',
MarkAsRead = 'MARK_AS_READ',
Delete = 'DELETE',
SendNotification = 'SEND_NOTIFICATION',
}