diff --git a/handlers/user-event.ts b/handlers/user-event.ts index 39b5a21..7337be9 100644 --- a/handlers/user-event.ts +++ b/handlers/user-event.ts @@ -5,7 +5,7 @@ import Article from "../models/article.ts"; import Profile from "../models/profile.ts"; import { articleHtml } from "../html.ts"; import notFoundHandler from "../handlers/not-found.ts"; -import generateOgProfileImage from "../tasks/generate_og_profile_image.ts"; +import { generateOgProfileImage } from "../magick.ts"; const userEventHandler = async function (ctx: Context) { const username = ctx.state.username.replace(/^(@|~)/, ""); diff --git a/handlers/user-profile.ts b/handlers/user-profile.ts index 042bc85..f8062b3 100644 --- a/handlers/user-profile.ts +++ b/handlers/user-profile.ts @@ -5,7 +5,7 @@ import Article from "../models/article.ts"; import Profile from "../models/profile.ts"; import { profilePageHtml } from "../html.ts"; import notFoundHandler from "../handlers/not-found.ts"; -import generateOgProfileImage from "../tasks/generate_og_profile_image.ts"; +import { generateOgProfileImage } from "../magick.ts"; const userProfileHandler = async function (ctx: Context) { const username = ctx.state.path.replace(/^(@|~)/, ""); diff --git a/tasks/generate_og_profile_image.ts b/magick.ts similarity index 78% rename from tasks/generate_og_profile_image.ts rename to magick.ts index 9dc91dd..9d58962 100644 --- a/tasks/generate_og_profile_image.ts +++ b/magick.ts @@ -1,10 +1,10 @@ -import Profile from "../models/profile.ts"; -import { checkIfFileExists, runCommand } from "../utils.ts"; -import { log } from "../log.ts"; +import Profile from "./models/profile.ts"; +import { checkIfFileExists, runCommand } from "./utils.ts"; +import { log } from "./log.ts"; const tmpImgDir = "/tmp/substr/img"; -const createRoundedImage = function (profile: Profile) { +function createRoundedImage(profile: Profile) { const command = [ 'magick', profile.picture, @@ -23,7 +23,7 @@ const createRoundedImage = function (profile: Profile) { return runCommand(command); } -const createOgImage = async function (profile: Profile, ogImagePath: string, backgroundColor: string) { +async function createOgImage(profile: Profile, ogImagePath: string, backgroundColor: string) { const status = await createRoundedImage(profile); if (status.success) { @@ -43,7 +43,7 @@ const createOgImage = async function (profile: Profile, ogImagePath: string, bac } }; -const generateOgProfileImage = async function(profile: Profile) { +export async function generateOgProfileImage(profile: Profile) { if (!profile.picture) return false; const ogImagePath = `${tmpImgDir}/og-p-${profile.event.id}.png`; @@ -59,5 +59,3 @@ const generateOgProfileImage = async function(profile: Profile) { } } } - -export default generateOgProfileImage;