forked from shadowfacts/Tusker
30 lines
779 B
Swift
30 lines
779 B
Swift
//
|
|
// DeleteFilterService.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 12/3/22.
|
|
// Copyright © 2022 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Pachyderm
|
|
|
|
@MainActor
|
|
class DeleteFilterService {
|
|
private let filter: FilterMO
|
|
private let mastodonController: MastodonController
|
|
|
|
init(filter: FilterMO, mastodonController: MastodonController) {
|
|
self.filter = filter
|
|
self.mastodonController = mastodonController
|
|
}
|
|
|
|
func run() async throws {
|
|
let req = FilterV1.delete(filter.id)
|
|
_ = try await mastodonController.run(req)
|
|
let context = mastodonController.persistentContainer.viewContext
|
|
context.delete(filter)
|
|
mastodonController.persistentContainer.save(context: context)
|
|
}
|
|
}
|