unattached-media: cid --> url
This commit is contained in:
parent
c88b174d02
commit
e8053ba072
|
@ -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),
|
||||
|
|
|
@ -50,7 +50,7 @@ interface RelayRow {
|
|||
interface UnattachedMediaRow {
|
||||
id: string;
|
||||
pukey: string;
|
||||
cid: string;
|
||||
url: string;
|
||||
data: string;
|
||||
uploaded_at: Date;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { uuid62 } from '@/deps.ts';
|
|||
interface UnattachedMedia {
|
||||
id: string;
|
||||
pukey: string;
|
||||
cid: string;
|
||||
url: string;
|
||||
data: {
|
||||
name?: string;
|
||||
mime?: string;
|
||||
|
|
Loading…
Reference in New Issue