mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
This commit is contained in:
parent
54775f79c5
commit
74d6bfbe77
3 changed files with 2 additions and 31 deletions
|
|
@ -21,7 +21,6 @@
|
||||||
"astro": "^5.3.0",
|
"astro": "^5.3.0",
|
||||||
"astro-icon": "^1.1.1",
|
"astro-icon": "^1.1.1",
|
||||||
"astro-seo": "^0.8.4",
|
"astro-seo": "^0.8.4",
|
||||||
"axios": "^1.8.1",
|
|
||||||
"better-auth": "^1.1.11",
|
"better-auth": "^1.1.11",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"decode-formdata": "^0.9.0",
|
"decode-formdata": "^0.9.0",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Prisma } from '@prisma/client'
|
import { Prisma } from '@prisma/client'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import prismaClient from 'utils/prisma-client'
|
import prismaClient from 'utils/prisma-client'
|
||||||
import { getImage } from 'astro:assets'
|
|
||||||
|
|
||||||
import { WEBHOOK_URL } from 'astro:env/server'
|
import { WEBHOOK_URL } from 'astro:env/server'
|
||||||
|
|
||||||
|
|
@ -13,29 +12,11 @@ type AlbumArtistNames = Prisma.albumsGetPayload<typeof albumArtistNames>
|
||||||
async function postWebhook(album: AlbumArtistNames, userText = '') {
|
async function postWebhook(album: AlbumArtistNames, userText = '') {
|
||||||
const url = `https://www.sittingonclouds.net/album/${album.id}`
|
const url = `https://www.sittingonclouds.net/album/${album.id}`
|
||||||
const content = `${url}${userText}`
|
const content = `${url}${userText}`
|
||||||
const artistNames = album.artists.map((a) => a.artist.name)
|
const payload = { content }
|
||||||
const coverImage = await getImage({
|
|
||||||
src: `https://cdn.sittingonclouds.net/album/${album.id}.png`,
|
|
||||||
height: 150,
|
|
||||||
width: 150
|
|
||||||
})
|
|
||||||
const embeds = [
|
|
||||||
{
|
|
||||||
title: album.title,
|
|
||||||
type: 'rich',
|
|
||||||
description: album.subTitle || artistNames.join(' - '),
|
|
||||||
url,
|
|
||||||
color: parseInt(album.headerColor.substring(1), 16),
|
|
||||||
thumbnail: { url: `https://www.sittingonclouds.net${coverImage.src}` }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const payload = { content, embeds }
|
|
||||||
await axios.post(WEBHOOK_URL, payload)
|
await axios.post(WEBHOOK_URL, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const requestPOST = (operation: string, body: any) => axios.post(`http://localhost:7001/${operation}`, body)
|
|
||||||
|
|
||||||
export async function handleComplete(album: AlbumArtistNames, requestId?: number) {
|
export async function handleComplete(album: AlbumArtistNames, requestId?: number) {
|
||||||
if (requestId) {
|
if (requestId) {
|
||||||
const request = await prismaClient.requests.findUnique({
|
const request = await prismaClient.requests.findUnique({
|
||||||
|
|
@ -44,7 +25,7 @@ export async function handleComplete(album: AlbumArtistNames, requestId?: number
|
||||||
})
|
})
|
||||||
if (!request || request.state === 'complete') return
|
if (!request || request.state === 'complete') return
|
||||||
|
|
||||||
await requestPOST('complete', { requestId: request.id })
|
await fetch('http://localhost:7001/complete', { method: 'POST', body: JSON.stringify({ requestId: request.id }) })
|
||||||
|
|
||||||
const userText =
|
const userText =
|
||||||
request.userID || request.user
|
request.userID || request.user
|
||||||
|
|
|
||||||
|
|
@ -2471,15 +2471,6 @@ axios@^1.6.0, axios@^1.7.4, axios@^1.7.9:
|
||||||
form-data "^4.0.0"
|
form-data "^4.0.0"
|
||||||
proxy-from-env "^1.1.0"
|
proxy-from-env "^1.1.0"
|
||||||
|
|
||||||
axios@^1.8.1:
|
|
||||||
version "1.8.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/axios/-/axios-1.8.1.tgz#7c118d2146e9ebac512b7d1128771cdd738d11e3"
|
|
||||||
integrity sha512-NN+fvwH/kV01dYUQ3PTOZns4LWtWhOFCAhQ/pHb88WQ1hNe5V/dvFwc4VJcDL11LT9xSX0QtsR8sWUuyOuOq7g==
|
|
||||||
dependencies:
|
|
||||||
follow-redirects "^1.15.6"
|
|
||||||
form-data "^4.0.0"
|
|
||||||
proxy-from-env "^1.1.0"
|
|
||||||
|
|
||||||
axobject-query@^4.1.0:
|
axobject-query@^4.1.0:
|
||||||
version "4.1.0"
|
version "4.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-4.1.0.tgz#28768c76d0e3cff21bc62a9e2d0b6ac30042a1ee"
|
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-4.1.0.tgz#28768c76d0e3cff21bc62a9e2d0b6ac30042a1ee"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue