You've already forked obsidian-visualiser
Campaign sheet start
This commit is contained in:
@@ -33,8 +33,6 @@ export default defineEventHandler(async (e) => {
|
||||
|
||||
tx.update(campaignTable).set({ link: cryptURI('campaign', id) }).where(eq(campaignTable.id, id)).run();
|
||||
|
||||
tx.insert(campaignMembersTable).values({ id, rights: 'dm', user: session.user!.id }).run();
|
||||
|
||||
return id;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { eq, not, sql } from 'drizzle-orm';
|
||||
import useDatabase from '~/composables/useDatabase';
|
||||
import type { Campaign } from '~/types/campaign';
|
||||
|
||||
export default defineEventHandler(async (e) => {
|
||||
const id = getRouterParam(e, "id");
|
||||
@@ -19,17 +20,18 @@ export default defineEventHandler(async (e) => {
|
||||
const db = useDatabase();
|
||||
const data = db.query.campaignTable.findFirst({
|
||||
with: {
|
||||
members: { with: { member: { columns: { username: true, id: true } } }, columns: { }, where: ({ rights }) => not(eq(rights, 'dm')), extras: { 'characters': sql`NULL`.as('characters') } },
|
||||
members: { with: { member: { columns: { username: true, id: true } } }, columns: { id: false, rights: false, user: false }, extras: { 'characters': sql`NULL`.as('characters') } },
|
||||
characters: { with: { character: { columns: { id: true, name: true, owner: true } } } },
|
||||
owner: { columns: { username: true, id: true } },
|
||||
logs: { columns: { details: true, from: true, timestamp: true, type: true }, orderBy: ({ timestamp }) => timestamp }
|
||||
},
|
||||
where: ({ id: _id }) => eq(_id, parseInt(id, 10)),
|
||||
}).sync();
|
||||
|
||||
if(data && (data.owner.id === session.user.id || data.members.find(e => e.member?.id === session.user!.id)))
|
||||
{
|
||||
data.members.forEach(e => e.characters = data.characters.filter(_e => _e.character?.owner === e.member?.id))
|
||||
return data;
|
||||
data.members.forEach(e => e.characters = data.characters.filter(_e => _e.character?.owner === e.member?.id));
|
||||
return data as Campaign;
|
||||
}
|
||||
else if(!data) return setResponseStatus(e, 404);
|
||||
else return setResponseStatus(e, 403);
|
||||
|
||||
17
server/components/mail/base.ts
Normal file
17
server/components/mail/base.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { dom } from '#shared/dom';
|
||||
|
||||
export default function(content: HTMLElement[])
|
||||
{
|
||||
return [dom('div', { style: 'margin-left: auto; margin-right: auto; width: 75%; font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 1rem; line-height: 1.5rem; color: #171717;' }, [
|
||||
dom('div', { style: 'margin-left: auto; margin-right: auto; text-align: center;' }, [
|
||||
dom('a', { style: 'display: inline-block;', attributes: { href: 'https://d-any.com' } }, [
|
||||
dom('img', { style: 'display: block; height: 4rem; width: 4rem; margin-left: auto; margin-right: auto;', attributes: { src: 'https://d-any.com/logo.light.png', alt: 'Logo', title: 'd[any] logo', width: '64', height: '64' } })
|
||||
dom('span', { style: `margin-inline-end: 1rem; font-size: 1.5rem; color: black; text-decoration: none; line-height: 2rem; font-weight: 700; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;`, text: 'd[any]' })
|
||||
])
|
||||
]),
|
||||
dom('div', { style: 'padding: 1rem;' }, content)
|
||||
]),
|
||||
dom('div', { style: 'margin-left: auto; margin-right: auto; width: 75%; font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 1rem; line-height: 1.5rem; color: #171717;' }, [
|
||||
dom('p', { style: 'padding-top: 1rem; padding-bottom: 1rem; text-align: center; font-size: 0.75rem; line-height: 1rem; color: #fff;', text: 'Copyright Peaceultime / d[any] - 2024 / 2025' })
|
||||
])]
|
||||
}
|
||||
@@ -1,22 +1,30 @@
|
||||
const TRIGGER_CHAR = {
|
||||
PING: String.fromCharCode(0x02),
|
||||
PONG: String.fromCharCode(0x03),
|
||||
STATUS: String.fromCharCode(0x04),
|
||||
};
|
||||
|
||||
export default defineWebSocketHandler({
|
||||
message(peer, message) {
|
||||
|
||||
switch(message.rawData)
|
||||
{
|
||||
case TRIGGER_CHAR.PING:
|
||||
peer.send(TRIGGER_CHAR.PONG);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
},
|
||||
open(peer) {
|
||||
const id = new URL(peer.request.url).pathname.split('/').slice(-1)[0];
|
||||
if(!id) return peer.close();
|
||||
peer.subscribe(`campaigns/${id}`);
|
||||
peer.publish(`campaigns/${id}`, true);
|
||||
|
||||
|
||||
peer.publish(`campaigns/${id}`, `${TRIGGER_CHAR.STATUS}`);
|
||||
},
|
||||
close(peer, details) {
|
||||
const id = new URL(peer.request.url).pathname.split('/').slice(-1)[0];
|
||||
if(!id) return peer.close();
|
||||
peer.publish(`campaigns/${id}`, false);
|
||||
peer.unsubscribe(`campaigns/${id}`);
|
||||
},
|
||||
error(peer, error) {
|
||||
console.error(error);
|
||||
}
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user