chore: add prettier formatting
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import Database from "better-sqlite3";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { DEFAULT_TEMPERATURE_UNIT, DEFAULT_WIND_SPEED_UNIT, isTemperatureUnit, isWindSpeedUnit } from "@/lib/weather-utils";
|
||||
import {
|
||||
DEFAULT_TEMPERATURE_UNIT,
|
||||
DEFAULT_WIND_SPEED_UNIT,
|
||||
isTemperatureUnit,
|
||||
isWindSpeedUnit,
|
||||
} from "@/lib/weather-utils";
|
||||
import type { WarningPushSubscription } from "@/types/notifications";
|
||||
import type { Province } from "@/types/province";
|
||||
import type { WeatherRegion } from "@/types/weather-region";
|
||||
@@ -121,7 +126,7 @@ function parseSubscription(row: PushSubscriptionRow): WarningPushSubscription |
|
||||
return {
|
||||
endpoint: row.endpoint,
|
||||
subscription,
|
||||
province: row.province === "global" ? null : row.province as Province,
|
||||
province: row.province === "global" ? null : (row.province as Province),
|
||||
region,
|
||||
language: row.language === "en" ? "en" : "pl",
|
||||
enabled: row.enabled === 1,
|
||||
@@ -143,7 +148,9 @@ function parseSubscription(row: PushSubscriptionRow): WarningPushSubscription |
|
||||
}
|
||||
|
||||
export function upsertPushSubscription(subscription: WarningPushSubscription) {
|
||||
getDatabase().prepare(`
|
||||
getDatabase()
|
||||
.prepare(
|
||||
`
|
||||
INSERT INTO push_subscriptions (
|
||||
endpoint,
|
||||
subscription_json,
|
||||
@@ -197,25 +204,27 @@ export function upsertPushSubscription(subscription: WarningPushSubscription) {
|
||||
temperature_unit = excluded.temperature_unit,
|
||||
wind_speed_unit = excluded.wind_speed_unit,
|
||||
updated_at = excluded.updated_at
|
||||
`).run({
|
||||
endpoint: subscription.endpoint,
|
||||
subscriptionJson: JSON.stringify(subscription.subscription),
|
||||
province: subscription.province ?? "global",
|
||||
region: subscription.region,
|
||||
language: subscription.language,
|
||||
enabled: subscription.enabled ? 1 : 0,
|
||||
morningBriefEnabled: subscription.morningBriefEnabled ? 1 : 0,
|
||||
tomorrowBriefEnabled: subscription.tomorrowBriefEnabled ? 1 : 0,
|
||||
latitude: subscription.latitude,
|
||||
longitude: subscription.longitude,
|
||||
locationName: subscription.locationName,
|
||||
timezone: subscription.timezone,
|
||||
countyTeryt: subscription.countyTeryt,
|
||||
temperatureUnit: subscription.temperatureUnit,
|
||||
windSpeedUnit: subscription.windSpeedUnit,
|
||||
createdAt: subscription.createdAt,
|
||||
updatedAt: subscription.updatedAt,
|
||||
});
|
||||
`,
|
||||
)
|
||||
.run({
|
||||
endpoint: subscription.endpoint,
|
||||
subscriptionJson: JSON.stringify(subscription.subscription),
|
||||
province: subscription.province ?? "global",
|
||||
region: subscription.region,
|
||||
language: subscription.language,
|
||||
enabled: subscription.enabled ? 1 : 0,
|
||||
morningBriefEnabled: subscription.morningBriefEnabled ? 1 : 0,
|
||||
tomorrowBriefEnabled: subscription.tomorrowBriefEnabled ? 1 : 0,
|
||||
latitude: subscription.latitude,
|
||||
longitude: subscription.longitude,
|
||||
locationName: subscription.locationName,
|
||||
timezone: subscription.timezone,
|
||||
countyTeryt: subscription.countyTeryt,
|
||||
temperatureUnit: subscription.temperatureUnit,
|
||||
windSpeedUnit: subscription.windSpeedUnit,
|
||||
createdAt: subscription.createdAt,
|
||||
updatedAt: subscription.updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
export function removePushSubscription(endpoint: string) {
|
||||
|
||||
Reference in New Issue
Block a user