diff --git a/CHANGELOG.md b/CHANGELOG.md index fbe1f1fe..59a0a66b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.16.2](https://github.com/Pjaijai/Referalah/compare/v1.16.0...v1.16.2) (2024-04-23) + + +### Bug Fixes + +* fix post history card ([60e0229](https://github.com/Pjaijai/Referalah/commit/60e022965003b69f28bb28b9ee46cd78f6fe01f6)) +* fix post nav description ([33622b3](https://github.com/Pjaijai/Referalah/commit/33622b367ca4f16be38917cb2a14ecaa63d19ec2)) +* fix post referee title ([621f5db](https://github.com/Pjaijai/Referalah/commit/621f5dbc563c4b458c5d11df84797546ace5a23b)) +* fix typo ([17cc97b](https://github.com/Pjaijai/Referalah/commit/17cc97b3ee6dd64a4d7c987db5ea108f14feac5d)) +* fothix edge function get user null problem ([025eefb](https://github.com/Pjaijai/Referalah/commit/025eefb7015190b7f07dcc216635366e44abd32b)) + ### [1.16.1](https://github.com/Pjaijai/Referalah/compare/v1.16.0...v1.16.1) (2024-04-22) ## [1.16.0](https://github.com/Pjaijai/Referalah/compare/v1.15.0...v1.16.0) (2024-04-22) diff --git a/package.json b/package.json index 2b38731d..0ab55c3a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Referalah", "description": "An open source online platform for oversea Hong Kong People to connect each other", - "version": "1.16.1", + "version": "1.16.2", "license": "Apache-2.0", "scripts": { "prepare": "husky install .husky", diff --git a/supabase/functions/message-post-creator/index.ts b/supabase/functions/message-post-creator/index.ts index 3668218f..812efa6d 100644 --- a/supabase/functions/message-post-creator/index.ts +++ b/supabase/functions/message-post-creator/index.ts @@ -4,48 +4,52 @@ import { initSupabaseClient } from "../_shared/client.ts" import { corsHeaders, ENV_IS_LOCAL } from "../_shared/cors.ts" import { EPostStatus } from "../_shared/types/enums/post/status.ts" import { initSupabaseServer } from "../_shared/server.ts" +import { createClient } from "https://esm.sh/@supabase/supabase-js@2" const RESEND_API_KEY = Deno.env.get("RESEND_API_KEY") const WEB_BASE_URL = Deno.env.get("WEB_BASE_URL") serve(async (req: any) => { - if (req.method === "OPTIONS") { - return new Response("ok", { headers: corsHeaders }) - } + try { + if (req.method === "OPTIONS") { + return new Response("ok", { headers: corsHeaders }) + } - const client = initSupabaseClient(req) - const server = initSupabaseServer() - const { post_uuid, body: msgBody, document } = await req.json() + const client = initSupabaseClient(req) + const server = initSupabaseServer() - if (!client) { - return new Response("User not signed in", { - headers: { ...corsHeaders, "Content-Type": "application/json" }, - status: 400, - }) - } + const jwt = req.headers.get("Authorization")!.split(" ")[1] - if (!msgBody) { - return new Response("Missing Message", { - headers: { ...corsHeaders, "Content-Type": "application/json" }, - status: 400, - }) - } - if (!post_uuid) { - return new Response("Missing post uuid", { - headers: { ...corsHeaders, "Content-Type": "application/json" }, - status: 400, - }) - } - if (msgBody.length > 4000) { - return new Response("Message too long", { - headers: { ...corsHeaders, "Content-Type": "application/json" }, - status: 400, - }) - } - try { - const { - data: { user }, - } = await client.auth.getUser() + const { post_uuid, body: msgBody, document } = await req.json() + + if (!client) { + return new Response("User not signed in", { + headers: { ...corsHeaders, "Content-Type": "application/json" }, + status: 400, + }) + } + + if (!msgBody) { + return new Response("Missing Message", { + headers: { ...corsHeaders, "Content-Type": "application/json" }, + status: 400, + }) + } + if (!post_uuid) { + return new Response("Missing post uuid", { + headers: { ...corsHeaders, "Content-Type": "application/json" }, + status: 400, + }) + } + if (msgBody.length > 4000) { + return new Response("Message too long", { + headers: { ...corsHeaders, "Content-Type": "application/json" }, + status: 400, + }) + } + + const { data: usera, error: useree } = await server.auth.getUser(jwt) + const { user } = usera const { data: sender, error } = await server .from("user") @@ -183,7 +187,7 @@ serve(async (req: any) => { .insert({ sender_uuid: sender.uuid, post_uuid: post.uuid, - type: "referer", + type: post.type, message_uuid: messageUuid, }) diff --git a/supabase/functions/message-referral/index.ts b/supabase/functions/message-referral/index.ts index 5d642c10..742fff37 100644 --- a/supabase/functions/message-referral/index.ts +++ b/supabase/functions/message-referral/index.ts @@ -15,6 +15,8 @@ serve(async (req: any) => { const client = initSupabaseClient(req) const server = initSupabaseServer() + + const jwt = req.headers.get("Authorization")!.split(" ")[1] const { type, body: msgBody, @@ -47,7 +49,7 @@ serve(async (req: any) => { const { data: { user }, - } = await client.auth.getUser() + } = await client.auth.getUser(jwt) const { data: sender, error } = await server .from("user")