2026-03-16 01:30:02 +00:00
|
|
|
import { LocationSource } from "@aelis/source-location"
|
|
|
|
|
|
|
|
|
|
import type { Database } from "../db/index.ts"
|
|
|
|
|
import type { FeedSourceProvider } from "../session/feed-source-provider.ts"
|
|
|
|
|
|
|
|
|
|
import { SourceDisabledError } from "../sources/errors.ts"
|
|
|
|
|
import { sources } from "../sources/user-sources.ts"
|
|
|
|
|
|
|
|
|
|
export class LocationSourceProvider implements FeedSourceProvider {
|
2026-03-19 23:27:19 +00:00
|
|
|
readonly sourceId = "aelis.location"
|
2026-03-16 01:30:02 +00:00
|
|
|
private readonly db: Database
|
|
|
|
|
|
|
|
|
|
constructor(db: Database) {
|
|
|
|
|
this.db = db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async feedSourceForUser(userId: string): Promise<LocationSource> {
|
|
|
|
|
const row = await sources(this.db, userId).find("aelis.location")
|
|
|
|
|
|
|
|
|
|
if (!row || !row.enabled) {
|
|
|
|
|
throw new SourceDisabledError("aelis.location", userId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new LocationSource()
|
|
|
|
|
}
|
|
|
|
|
}
|