diff options
| author | Fuwn <[email protected]> | 2024-07-25 00:19:44 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-07-25 00:20:23 -0700 |
| commit | 2d9235070856c0a5032ddf47f7b1dc7cc5cceb60 (patch) | |
| tree | 4677f0355872a0f7f55d38a372ec5e3870771182 /src/lib/Database/userNotifications.ts | |
| parent | feat(notifications): allow unsubscribe (diff) | |
| download | due.moe-2d9235070856c0a5032ddf47f7b1dc7cc5cceb60.tar.xz due.moe-2d9235070856c0a5032ddf47f7b1dc7cc5cceb60.zip | |
refactor(Database): separate providers
Diffstat (limited to 'src/lib/Database/userNotifications.ts')
| -rw-r--r-- | src/lib/Database/userNotifications.ts | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/lib/Database/userNotifications.ts b/src/lib/Database/userNotifications.ts deleted file mode 100644 index 6516b813..00000000 --- a/src/lib/Database/userNotifications.ts +++ /dev/null @@ -1,32 +0,0 @@ -import supabase from './supabase'; - -export interface UserNotifications { - created_at: string; - updated_at: string; - user_id: number; - subscription: JSON; -} - -export const getUserSubscription = async (userId: number) => - await supabase.from('user_notifications').select('*').eq('user_id', userId); - -export const getUserSubscriptions = async () => { - const { data, error } = await supabase.from('user_notifications').select('*'); - - if (error) return []; - - return data as UserNotifications[]; -}; - -export const deleteUserSubscription = async (userId: number) => - await supabase.from('user_notifications').delete().eq('user_id', userId); - -export const setUserSubscription = async (userId: number, subscription: JSON) => - await supabase.from('user_notifications').upsert( - { - user_id: userId, - updated_at: new Date().toISOString(), - subscription: subscription - }, - { onConflict: 'user_id' } - ); |