diff --git a/apps/atrium-telegram/.env.example b/apps/atrium-telegram/.env.example index 412dc774..5aced96d 100644 --- a/apps/atrium-telegram/.env.example +++ b/apps/atrium-telegram/.env.example @@ -1,6 +1,9 @@ # Main database DATABASE_URL= +# Main API +NUXT_PUBLIC_CORE_API_URL= + # Telegram NUXT_TELEGRAM_ADMIN_ID= NUXT_TELEGRAM_ATRIUM_BOT_ID= diff --git a/apps/atrium-telegram/app/app.vue b/apps/atrium-telegram/app/app.vue index ebb083b5..064c770c 100644 --- a/apps/atrium-telegram/app/app.vue +++ b/apps/atrium-telegram/app/app.vue @@ -4,7 +4,7 @@ :tooltip="{ delayDuration: 0 }" :toaster="{ position: 'top-center', - class: 'mt-16', + class: 'mt-20', }" class="min-h-svh" > diff --git a/apps/atrium-telegram/app/components/form/CreateEpicCommentBeacon.vue b/apps/atrium-telegram/app/components/form/CreateEpicCommentBeacon.vue index ef954fd5..066e91fa 100644 --- a/apps/atrium-telegram/app/components/form/CreateEpicCommentBeacon.vue +++ b/apps/atrium-telegram/app/components/form/CreateEpicCommentBeacon.vue @@ -58,9 +58,7 @@ const emit = defineEmits(['success', 'submitted']) type FormMember = { label: string, value: string, avatar: { src: string | undefined, alt: string } } -const { t } = useI18n() const { vibrate } = useFeedback() -const actionToast = useActionToast() const userStore = useUserStore() const epicStore = useEpicStore() @@ -94,11 +92,10 @@ watch(selectedMembers, () => { }) async function onSubmit(event: FormSubmitEvent) { - const toastId = actionToast.start() emit('submitted') try { - await $fetch(`https://atrium.sushi-love.ru/api/epic/comment/id/${commentId}/beacon`, { + await $fetch(`/api/epic/comment/id/${commentId}/beacon`, { method: 'POST', body: event.data, }) @@ -109,12 +106,10 @@ async function onSubmit(event: FormSubmitEvent) { notificationStore.update(), ]) - actionToast.success(toastId, t('toast.beacon-created')) vibrate('success') emit('success') } catch (error) { console.error(error) - actionToast.error(toastId) vibrate('error') } } diff --git a/apps/atrium-telegram/app/components/form/UploadUserAvatar.vue b/apps/atrium-telegram/app/components/form/UploadUserAvatar.vue index 4fa7d698..dad9ad86 100644 --- a/apps/atrium-telegram/app/components/form/UploadUserAvatar.vue +++ b/apps/atrium-telegram/app/components/form/UploadUserAvatar.vue @@ -64,11 +64,10 @@ async function onSubmit(event: FormSubmitEvent) { const formData = new FormData() formData.append('file', event.data.file) - await $fetch(`/api/user/id/${userStore.id}/image`, { + const { public: publicEnv } = useRuntimeConfig() + + await $fetch(`${publicEnv.coreApiUrl}/user/id/${userStore.id}/image`, { method: 'POST', - headers: { - Authorization: `tma ${userStore.initDataRaw}`, - }, body: formData, }) diff --git a/apps/atrium-telegram/nuxt.config.ts b/apps/atrium-telegram/nuxt.config.ts index de31a4df..67629995 100644 --- a/apps/atrium-telegram/nuxt.config.ts +++ b/apps/atrium-telegram/nuxt.config.ts @@ -24,6 +24,9 @@ export default defineNuxtConfig({ adminId: '', teamGroupId: '', }, + public: { + coreApiUrl: '', + }, }, ui: { colorMode: true, diff --git a/apps/atrium-telegram/server/api/epic/comment/id/[commentId]/beacon.post.ts b/apps/atrium-telegram/server/api/epic/comment/id/[commentId]/beacon.post.ts new file mode 100644 index 00000000..518a8726 --- /dev/null +++ b/apps/atrium-telegram/server/api/epic/comment/id/[commentId]/beacon.post.ts @@ -0,0 +1,33 @@ +import { createBeaconSchema } from '#shared/services/notification' +import { type } from 'arktype' + +export default defineEventHandler(async (event) => { + try { + const commentId = getRouterParam(event, 'commentId') + if (!commentId) { + throw createError({ + statusCode: 400, + message: 'Id is required', + }) + } + + const body = await readBody(event) + const data = createBeaconSchema(body) + if (data instanceof type.errors) { + throw data + } + + const { public: publicEnv } = useRuntimeConfig() + + await $fetch(`${publicEnv.coreApiUrl}/epic/comment/id/${commentId}/beacon`, { + method: 'POST', + body: data, + }) + + return { + ok: true, + } + } catch (error) { + throw errorResolver(error) + } +}) diff --git a/apps/atrium-telegram/shared/services/media.ts b/apps/atrium-telegram/shared/services/media.ts index 75b5e5f2..e39d4e80 100644 --- a/apps/atrium-telegram/shared/services/media.ts +++ b/apps/atrium-telegram/shared/services/media.ts @@ -7,6 +7,8 @@ const ACCEPTED_IMAGE_TYPES = [ 'image/png', 'image/webp', 'image/gif', + 'image/avif', + 'image/heif', ] const FileSchema = type('File') diff --git a/apps/web-app/server/api/user/id/[userId]/image.post.ts b/apps/web-app/server/api/user/id/[userId]/image.post.ts index 92aeb760..accc84dc 100644 --- a/apps/web-app/server/api/user/id/[userId]/image.post.ts +++ b/apps/web-app/server/api/user/id/[userId]/image.post.ts @@ -7,7 +7,7 @@ const USER_AVATARS_DIRECTORY = 'users' const IMAGE_SIZES = [256, 512] const IMAGE_FORMATS = ['jpg', 'webp'] as const -const ACCEPTED_IMAGE_FORMATS = ['jpeg', 'jpg', 'png', 'webp'] +const ACCEPTED_IMAGE_FORMATS = ['jpeg', 'jpg', 'png', 'webp', 'heif', 'avif'] export default defineEventHandler(async (event) => { let sharpStream diff --git a/apps/web-app/shared/services/media.ts b/apps/web-app/shared/services/media.ts index 75b5e5f2..e39d4e80 100644 --- a/apps/web-app/shared/services/media.ts +++ b/apps/web-app/shared/services/media.ts @@ -7,6 +7,8 @@ const ACCEPTED_IMAGE_TYPES = [ 'image/png', 'image/webp', 'image/gif', + 'image/avif', + 'image/heif', ] const FileSchema = type('File')