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

Fix warning #76

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Models/Did.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum BanReason: String, Codable {
case missingHistory = "missing_history"
}

final class Did: Model, Content {
final class Did: Model, Content, @unchecked Sendable {
static let schema = "dids"

static func findWithOperations(_ did: Did.IDValue?, on db: Database) async throws -> Did? {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Models/Handle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ enum HandleNameError: Error {
case invalidCharacter
}

final class Handle: Model, Content {
final class Handle: Model, Content, @unchecked Sendable {
static let schema = "handles"

static func findBy(handleName: String, withOp: Bool = false, on db: Database) async throws
-> Handle?
{
let query = Handle.query(on: db).filter(\.$handle == handleName)
return try await if withOp {
query.with(\.$operations).first()
return if withOp {
try await query.with(\.$operations).first()
} else {
query.first()
try await query.first()
}
}

Expand Down
12 changes: 10 additions & 2 deletions Sources/Models/Middleware/DidMiddleware.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import Fluent
import Redis
import Vapor

struct DidMiddleware: AsyncModelMiddleware {
typealias Model = Did

let redis: RedisClient
let logger: Logger
let app: Application

var redis: RedisClient {
self.app.redis
}

var logger: Logger {
self.app.logger
}

func create(model: Model, on db: Database, next: AnyAsyncModelResponder) async throws {
try await next.create(model, on: db)
Expand Down
12 changes: 10 additions & 2 deletions Sources/Models/Middleware/HandleMiddleware.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import Fluent
import Redis
import Vapor

struct HandleMiddleware: AsyncModelMiddleware {
typealias Model = Handle

let redis: RedisClient
let logger: Logger
let app: Application

var redis: RedisClient {
self.app.redis
}

var logger: Logger {
self.app.logger
}

func create(model: Model, on db: Database, next: AnyAsyncModelResponder) async throws {
try await next.create(model, on: db)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Models/Operation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Fluent
import FluentPostgresDriver
import Vapor

final class Operation: Model, Content {
final class Operation: Model, Content, @unchecked Sendable {
static let schema = "operations"

final class IDValue: Fields, Hashable {
final class IDValue: Fields, Hashable, @unchecked Sendable {
@Field(key: "cid")
var cid: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/Models/PersonalDataServer.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent
import Vapor

final class PersonalDataServer: Model, Content {
final class PersonalDataServer: Model, Content, @unchecked Sendable {
static let schema = "personal_data_servers"

@ID(key: .id)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Models/PollingHistory.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent
import Vapor

final class PollingHistory: Model, Content {
final class PollingHistory: Model, Content, @unchecked Sendable {
static func getLatestWithoutErrors(on database: Database) async throws -> PollingHistory? {
let errors = try await PollingJobStatus.query(on: database).filter(\.$status == .error)
.all(\.$history.$id)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Models/PollingJobStatus.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent
import Vapor

final class PollingJobStatus: Model, Content {
final class PollingJobStatus: Model, Content, @unchecked Sendable {
static let schema = "polling_job_statuses"

@ID(custom: .id, generatedBy: .user)
Expand Down
2 changes: 1 addition & 1 deletion Sources/entrypoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum Entrypoint {
var env = try Environment.detect()
try LoggingSystem.bootstrap(from: &env)

let app = Application(env)
let app = try await Application.make(env)
defer { app.shutdown() }

try await configure(app)
Expand Down
4 changes: 2 additions & 2 deletions Sources/registerMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ func registerMiddleware(_ app: Application) {
FileMiddleware(publicDirectory: app.directory.publicDirectory, directoryAction: .redirect))

// database middleware
app.databases.middleware.use(DidMiddleware(redis: app.redis, logger: app.logger), on: .psql)
app.databases.middleware.use(HandleMiddleware(redis: app.redis, logger: app.logger), on: .psql)
app.databases.middleware.use(DidMiddleware(app: app), on: .psql)
app.databases.middleware.use(HandleMiddleware(app: app), on: .psql)
}