mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-19 14:29:21 -04:00
Fix: update avatar pic to be the same as pinned profile pic
This commit is contained in:
@@ -29,8 +29,9 @@ export const updateProfile: APIHandler<'update-profile'> = async (
|
||||
log('Updating profile', { userId: auth.uid, parsedBody })
|
||||
|
||||
await removePinnedUrlFromPhotoUrls(parsedBody)
|
||||
if (parsedBody.avatar_url) {
|
||||
await updateUser(pg, auth.uid, { avatarUrl: parsedBody.avatar_url })
|
||||
|
||||
if (parsedBody.pinned_url) {
|
||||
await updateUser(pg, auth.uid, {avatarUrl: parsedBody.pinned_url})
|
||||
}
|
||||
|
||||
const { data, error } = await tryCatch(
|
||||
|
||||
@@ -4,13 +4,13 @@ jest.mock("common/util/try-catch");
|
||||
jest.mock("shared/profiles/parse-photos");
|
||||
jest.mock("shared/supabase/users");
|
||||
|
||||
import { updateProfile } from "api/update-profile";
|
||||
import { AuthedUser } from "api/helpers/endpoint";
|
||||
import {updateProfile} from "api/update-profile";
|
||||
import {AuthedUser} from "api/helpers/endpoint";
|
||||
import * as supabaseInit from "shared/supabase/init";
|
||||
import * as supabaseUtils from "shared/supabase/utils";
|
||||
import * as supabaseUsers from "shared/supabase/users";
|
||||
import { tryCatch } from "common/util/try-catch";
|
||||
import { removePinnedUrlFromPhotoUrls } from "shared/profiles/parse-photos";
|
||||
import {tryCatch} from "common/util/try-catch";
|
||||
import {removePinnedUrlFromPhotoUrls} from "shared/profiles/parse-photos";
|
||||
|
||||
describe('updateProfiles', () => {
|
||||
let mockPg: any;
|
||||
@@ -30,7 +30,7 @@ describe('updateProfiles', () => {
|
||||
describe('when given valid input', () => {
|
||||
it('should update an existing profile when provided the user id', async () => {
|
||||
const mockProps = {
|
||||
avatar_url: "mockAvatarUrl"
|
||||
pinned_url: "mockAvatarUrl"
|
||||
};
|
||||
const mockAuth = { uid: '321' } as AuthedUser;
|
||||
const mockReq = {} as any;
|
||||
@@ -54,7 +54,7 @@ describe('updateProfiles', () => {
|
||||
expect(supabaseUsers.updateUser).toBeCalledWith(
|
||||
expect.any(Object),
|
||||
mockAuth.uid,
|
||||
{avatarUrl: mockProps.avatar_url}
|
||||
{avatarUrl: mockProps.pinned_url}
|
||||
);
|
||||
expect(supabaseUtils.update).toBeCalledTimes(1);
|
||||
expect(supabaseUtils.update).toBeCalledWith(
|
||||
|
||||
@@ -9,6 +9,9 @@ CREATE TABLE IF NOT EXISTS user_events (
|
||||
user_id TEXT
|
||||
);
|
||||
|
||||
alter table user_events
|
||||
add constraint user_events_user_id_fkey foreign key (user_id) references users (id) ON DELETE set null;
|
||||
|
||||
-- Row Level Security
|
||||
ALTER TABLE user_events ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user