diff --git a/backend/api/src/get-likes-and-ships.ts b/backend/api/src/get-likes-and-ships.ts index 5a024999..5c9bf7ab 100644 --- a/backend/api/src/get-likes-and-ships.ts +++ b/backend/api/src/get-likes-and-ships.ts @@ -20,10 +20,10 @@ export const getLikesAndShipsMain = async (userId: string) => { created_time: number }>( ` - select target_id, love_likes.created_time - from love_likes - join profiles on profiles.user_id = love_likes.target_id - join users on users.id = love_likes.target_id + select target_id, profile_likes.created_time + from profile_likes + join profiles on profiles.user_id = profile_likes.target_id + join users on users.id = profile_likes.target_id where creator_id = $1 and looking_for_matches and profiles.pinned_url is not null @@ -42,10 +42,10 @@ export const getLikesAndShipsMain = async (userId: string) => { created_time: number }>( ` - select creator_id, love_likes.created_time - from love_likes - join profiles on profiles.user_id = love_likes.creator_id - join users on users.id = love_likes.creator_id + select creator_id, profile_likes.created_time + from profile_likes + join profiles on profiles.user_id = profile_likes.creator_id + join users on users.id = profile_likes.creator_id where target_id = $1 and looking_for_matches and profiles.pinned_url is not null diff --git a/backend/api/src/has-free-like.ts b/backend/api/src/has-free-like.ts index 44014848..df7158c7 100644 --- a/backend/api/src/has-free-like.ts +++ b/backend/api/src/has-free-like.ts @@ -17,7 +17,7 @@ export const getHasFreeLike = async (userId: string) => { const likeGivenToday = await pg.oneOrNone( ` select 1 - from love_likes + from profile_likes where creator_id = $1 and created_time at time zone 'UTC' at time zone 'America/Los_Angeles' >= (now() at time zone 'UTC' at time zone 'America/Los_Angeles')::date and created_time at time zone 'UTC' at time zone 'America/Los_Angeles' < ((now() at time zone 'UTC' at time zone 'America/Los_Angeles')::date + interval '1 day') diff --git a/backend/api/src/like-profile.ts b/backend/api/src/like-profile.ts index 4726d7b9..2d9c7318 100644 --- a/backend/api/src/like-profile.ts +++ b/backend/api/src/like-profile.ts @@ -1,6 +1,6 @@ import { createSupabaseDirectClient } from 'shared/supabase/init' import { APIError, APIHandler } from './helpers/endpoint' -import { createLoveLikeNotification } from 'shared/create-love-notification' +import { createProfileLikeNotification } from 'shared/create-love-notification' import { getHasFreeLike } from './has-free-like' import { log } from 'shared/utils' import { tryCatch } from 'common/util/try-catch' @@ -15,7 +15,7 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => { if (remove) { const { error } = await tryCatch( pg.none( - 'delete from love_likes where creator_id = $1 and target_id = $2', + 'delete from profile_likes where creator_id = $1 and target_id = $2', [creatorId, targetUserId] ) ) @@ -28,8 +28,8 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => { // Check if like already exists const { data: existing } = await tryCatch( - pg.oneOrNone>( - 'select * from love_likes where creator_id = $1 and target_id = $2', + pg.oneOrNone>( + 'select * from profile_likes where creator_id = $1 and target_id = $2', [creatorId, targetUserId] ) ) @@ -48,8 +48,8 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => { // Insert the new like const { data, error } = await tryCatch( - pg.one>( - 'insert into love_likes (creator_id, target_id) values ($1, $2) returning *', + pg.one>( + 'insert into profile_likes (creator_id, target_id) values ($1, $2) returning *', [creatorId, targetUserId] ) ) @@ -59,7 +59,7 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => { } const continuation = async () => { - await createLoveLikeNotification(data) + await createProfileLikeNotification(data) } return { diff --git a/backend/shared/src/create-love-notification.ts b/backend/shared/src/create-love-notification.ts index 2b184954..8f19bab7 100644 --- a/backend/shared/src/create-love-notification.ts +++ b/backend/shared/src/create-love-notification.ts @@ -6,7 +6,7 @@ import { Notification } from 'common/notifications' import { insertNotificationToSupabase } from './supabase/notifications' import { getProfile } from './love/supabase' -export const createLoveLikeNotification = async (like: Row<'love_likes'>) => { +export const createProfileLikeNotification = async (like: Row<'profile_likes'>) => { const { creator_id, target_id, like_id } = like const targetPrivateUser = await getPrivateUser(target_id) @@ -16,7 +16,7 @@ export const createLoveLikeNotification = async (like: Row<'love_likes'>) => { const { sendToBrowser } = getNotificationDestinationsForUser( targetPrivateUser, - 'new_love_like' + 'new_profile_like' ) if (!sendToBrowser) return @@ -24,11 +24,11 @@ export const createLoveLikeNotification = async (like: Row<'love_likes'>) => { const notification: Notification = { id, userId: target_id, - reason: 'new_love_like', + reason: 'new_profile_like', createdTime: Date.now(), isSeen: false, sourceId: like_id, - sourceType: 'love_like', + sourceType: 'profile_like', sourceUpdateType: 'created', sourceUserName: profile.user.name, sourceUserUsername: profile.user.username, diff --git a/backend/supabase/migration.sql b/backend/supabase/migration.sql index 2b8b8892..7b23b31d 100644 --- a/backend/supabase/migration.sql +++ b/backend/supabase/migration.sql @@ -11,7 +11,7 @@ BEGIN; \i backend/supabase/prompt_answers.sql \i backend/supabase/profile_comments.sql \i backend/supabase/compatibility_answers.sql -\i backend/supabase/love_likes.sql +\i backend/supabase/profile_likes.sql \i backend/supabase/love_questions.sql \i backend/supabase/love_ships.sql \i backend/supabase/love_stars.sql diff --git a/backend/supabase/love_likes.sql b/backend/supabase/profile_likes.sql similarity index 58% rename from backend/supabase/love_likes.sql rename to backend/supabase/profile_likes.sql index c9e00645..cc4230bf 100644 --- a/backend/supabase/love_likes.sql +++ b/backend/supabase/profile_likes.sql @@ -1,17 +1,17 @@ -CREATE TABLE IF NOT EXISTS love_likes ( +CREATE TABLE IF NOT EXISTS profile_likes ( created_time TIMESTAMPTZ DEFAULT now() NOT NULL, creator_id TEXT NOT NULL, like_id TEXT DEFAULT random_alphanumeric(12) NOT NULL, target_id TEXT NOT NULL, - CONSTRAINT love_likes_pkey PRIMARY KEY (creator_id, like_id) + CONSTRAINT profile_likes_pkey PRIMARY KEY (creator_id, like_id) ); -- Row Level Security -ALTER TABLE love_likes ENABLE ROW LEVEL SECURITY; +ALTER TABLE profile_likes ENABLE ROW LEVEL SECURITY; -- Policies -DROP POLICY IF EXISTS "public read" ON love_likes; -CREATE POLICY "public read" ON love_likes +DROP POLICY IF EXISTS "public read" ON profile_likes; +CREATE POLICY "public read" ON profile_likes FOR SELECT USING (true); -- Indexes @@ -19,4 +19,4 @@ CREATE POLICY "public read" ON love_likes -- so we do not recreate that. Additional indexes: CREATE INDEX IF NOT EXISTS user_likes_target_id_raw - ON public.love_likes (target_id); + ON public.profile_likes (target_id); diff --git a/common/src/notifications.ts b/common/src/notifications.ts index 2d463872..a7e92675 100644 --- a/common/src/notifications.ts +++ b/common/src/notifications.ts @@ -32,7 +32,7 @@ export type Notification = { export const NOTIFICATION_TYPES_TO_SELECT = [ 'new_match', // new match markets 'comment_on_profile', // endorsements - 'love_like', + 'profile_like', 'love_ship', ] diff --git a/common/src/supabase/schema.ts b/common/src/supabase/schema.ts index 4c1bdd4a..745a4318 100644 --- a/common/src/supabase/schema.ts +++ b/common/src/supabase/schema.ts @@ -136,7 +136,7 @@ export type Database = { } Relationships: [] } - love_likes: { + profile_likes: { Row: { created_time: string creator_id: string diff --git a/common/src/user-notification-preferences.ts b/common/src/user-notification-preferences.ts index b7569e03..d8f623b8 100644 --- a/common/src/user-notification-preferences.ts +++ b/common/src/user-notification-preferences.ts @@ -6,7 +6,7 @@ export type notification_preference = keyof notification_preferences export type notification_preferences = { new_match: notification_destination_types[] new_endorsement: notification_destination_types[] - new_love_like: notification_destination_types[] + new_profile_like: notification_destination_types[] new_love_ship: notification_destination_types[] new_search_alerts: notification_destination_types[] @@ -40,7 +40,7 @@ export const getDefaultNotificationPreferences = (isDev?: boolean) => { new_match: constructPref(true, true, true), new_search_alerts: constructPref(true, true, true), new_endorsement: constructPref(true, true, true), - new_love_like: constructPref(true, false, false), + new_profile_like: constructPref(true, false, false), new_love_ship: constructPref(true, false, false), // User-related diff --git a/web/components/notification-items.tsx b/web/components/notification-items.tsx index 362d9c32..1682dba5 100644 --- a/web/components/notification-items.tsx +++ b/web/components/notification-items.tsx @@ -30,8 +30,8 @@ export function NotificationItem(props: { notification: Notification }) { return } else if (sourceType === 'new_match') { return - } else if (reason === 'new_love_like') { - return + } else if (reason === 'new_profile_like') { + return } else if (reason === 'new_love_ship') { return } else { @@ -119,7 +119,7 @@ export function NewMatchNotification(props: { ) } -function LoveLikeNotification(props: { +function ProfileLikeNotification(props: { notification: Notification highlighted: boolean setHighlighted: (highlighted: boolean) => void diff --git a/web/hooks/use-notifications.ts b/web/hooks/use-notifications.ts index d5f78629..680dfa36 100644 --- a/web/hooks/use-notifications.ts +++ b/web/hooks/use-notifications.ts @@ -53,8 +53,8 @@ function groupGeneralNotifications( new Date(n.createdTime).toDateString() + (n.sourceType === 'betting_streak_bonus' || n.reason === 'quest_payout' ? 'quest_payout' - : n.sourceType === 'love_like' - ? 'love_like' + : n.sourceType === 'profile_like' + ? 'profile_like' : n.sourceType === 'love_ship' ? 'love_ship' : n.data?.isPartner diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 11da222e..0efad59b 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -160,7 +160,7 @@ const LoadedNotificationSettings = (props: { privateUser: PrivateUser }) => { question: '... sends you a new message?', }, { - type: 'new_love_like', + type: 'new_profile_like', question: '... likes your profile?', }, {