You've already forked obsidian-visualiser
WebSocket API, new ID/encrypt/decrypt algorithm.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { z } from 'zod/v4';
|
||||
import useDatabase from '~/composables/useDatabase';
|
||||
import { campaignMembersTable, campaignTable } from '~/db/schema';
|
||||
import { campaignTable } from '~/db/schema';
|
||||
import { CampaignValidation } from '#shared/campaign.util';
|
||||
import { cryptURI } from '#shared/general.util';
|
||||
|
||||
@@ -26,13 +26,15 @@ export default defineEventHandler(async (e) => {
|
||||
const id = db.transaction((tx) => {
|
||||
const id = tx.insert(campaignTable).values({
|
||||
name: body.data.name,
|
||||
description: body.data.description,
|
||||
public_notes: body.data.public_notes,
|
||||
owner: session.user!.id,
|
||||
dm_notes: body.data.dm_notes,
|
||||
settings: body.data.settings,
|
||||
link: '',
|
||||
}).returning({ id: campaignTable.id }).get().id;
|
||||
|
||||
tx.update(campaignTable).set({ link: cryptURI('campaign', id) }).where(eq(campaignTable.id, id)).run();
|
||||
|
||||
|
||||
return id;
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export default defineEventHandler(async (e) => {
|
||||
members: { with: { member: { columns: { username: true, id: true } } }, columns: { id: false, user: false } },
|
||||
characters: { with: { character: { columns: { id: true, name: true, owner: true } } }, columns: { character: false } },
|
||||
owner: { columns: { username: true, id: true } },
|
||||
logs: { columns: { details: true, from: true, timestamp: true, type: true }, orderBy: ({ timestamp }) => timestamp },
|
||||
logs: { columns: { details: true, target: true, timestamp: true, type: true }, orderBy: ({ timestamp }) => timestamp },
|
||||
},
|
||||
where: ({ id: _id }) => eq(_id, parseInt(id, 10)),
|
||||
}).sync();
|
||||
|
||||
@@ -39,7 +39,9 @@ export default defineEventHandler(async (e) => {
|
||||
db.transaction((tx) => {
|
||||
tx.update(campaignTable).set({
|
||||
name: body.data.name,
|
||||
description: body.data.description,
|
||||
public_notes: body.data.public_notes,
|
||||
dm_notes: body.data.dm_notes,
|
||||
settings: body.data.settings,
|
||||
}).where(eq(campaignTable.id, id)).run();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export default defineEventHandler(async (e) => {
|
||||
columns: { username: true }
|
||||
},
|
||||
campaign: {
|
||||
columns: { character: false, id: false, },
|
||||
columns: { character: false, id: true, },
|
||||
with: {
|
||||
campaign: {
|
||||
columns: { owner: true, },
|
||||
@@ -70,6 +70,8 @@ export default defineEventHandler(async (e) => {
|
||||
owner: character.owner,
|
||||
username: character.user.username,
|
||||
visibility: character.visibility,
|
||||
|
||||
campaign: character.campaign?.id,
|
||||
} as Character;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user