unattached-media: cid --> url

This commit is contained in:
Alex Gleason 2023-09-09 18:12:54 -05:00
parent c88b174d02
commit e8053ba072
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 8 additions and 8 deletions

View File

@ -28,9 +28,11 @@ const mediaController: AppController = async (c) => {
const { file, description } = result.data;
const { cid } = await uploader.upload(file);
const url = new URL(`/ipfs/${cid}`, Conf.mediaDomain).toString();
await insertUnattachedMedia({
pukey: c.get('pubkey')!,
cid,
url,
data: {
name: file.name,
mime: file.type,
@ -39,8 +41,6 @@ const mediaController: AppController = async (c) => {
},
});
const url = new URL(`/ipfs/${cid}`, Conf.mediaDomain).toString();
return c.json({
id: cid,
type: getAttachmentType(file.type),

View File

@ -50,7 +50,7 @@ interface RelayRow {
interface UnattachedMediaRow {
id: string;
pukey: string;
cid: string;
url: string;
data: string;
uploaded_at: Date;
}

View File

@ -5,7 +5,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.createTable('unattached_media')
.addColumn('id', 'text', (c) => c.primaryKey())
.addColumn('pukey', 'text', (c) => c.notNull())
.addColumn('cid', 'text', (c) => c.notNull())
.addColumn('url', 'text', (c) => c.notNull())
.addColumn('data', 'text', (c) => c.notNull())
.addColumn('uploaded_at', 'datetime', (c) => c.notNull().defaultTo(sql`CURRENT_TIMESTAMP`))
.execute();
@ -23,9 +23,9 @@ export async function up(db: Kysely<any>): Promise<void> {
.execute();
await db.schema
.createIndex('unattached_media_cid')
.createIndex('unattached_media_url')
.on('unattached_media')
.column('cid')
.column('url')
.execute();
}

View File

@ -4,7 +4,7 @@ import { uuid62 } from '@/deps.ts';
interface UnattachedMedia {
id: string;
pukey: string;
cid: string;
url: string;
data: {
name?: string;
mime?: string;