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 { file, description } = result.data;
|
||||||
const { cid } = await uploader.upload(file);
|
const { cid } = await uploader.upload(file);
|
||||||
|
|
||||||
|
const url = new URL(`/ipfs/${cid}`, Conf.mediaDomain).toString();
|
||||||
|
|
||||||
await insertUnattachedMedia({
|
await insertUnattachedMedia({
|
||||||
pukey: c.get('pubkey')!,
|
pukey: c.get('pubkey')!,
|
||||||
cid,
|
url,
|
||||||
data: {
|
data: {
|
||||||
name: file.name,
|
name: file.name,
|
||||||
mime: file.type,
|
mime: file.type,
|
||||||
|
@ -39,8 +41,6 @@ const mediaController: AppController = async (c) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const url = new URL(`/ipfs/${cid}`, Conf.mediaDomain).toString();
|
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
id: cid,
|
id: cid,
|
||||||
type: getAttachmentType(file.type),
|
type: getAttachmentType(file.type),
|
||||||
|
|
|
@ -50,7 +50,7 @@ interface RelayRow {
|
||||||
interface UnattachedMediaRow {
|
interface UnattachedMediaRow {
|
||||||
id: string;
|
id: string;
|
||||||
pukey: string;
|
pukey: string;
|
||||||
cid: string;
|
url: string;
|
||||||
data: string;
|
data: string;
|
||||||
uploaded_at: Date;
|
uploaded_at: Date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||||
.createTable('unattached_media')
|
.createTable('unattached_media')
|
||||||
.addColumn('id', 'text', (c) => c.primaryKey())
|
.addColumn('id', 'text', (c) => c.primaryKey())
|
||||||
.addColumn('pukey', 'text', (c) => c.notNull())
|
.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('data', 'text', (c) => c.notNull())
|
||||||
.addColumn('uploaded_at', 'datetime', (c) => c.notNull().defaultTo(sql`CURRENT_TIMESTAMP`))
|
.addColumn('uploaded_at', 'datetime', (c) => c.notNull().defaultTo(sql`CURRENT_TIMESTAMP`))
|
||||||
.execute();
|
.execute();
|
||||||
|
@ -23,9 +23,9 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
await db.schema
|
await db.schema
|
||||||
.createIndex('unattached_media_cid')
|
.createIndex('unattached_media_url')
|
||||||
.on('unattached_media')
|
.on('unattached_media')
|
||||||
.column('cid')
|
.column('url')
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { uuid62 } from '@/deps.ts';
|
||||||
interface UnattachedMedia {
|
interface UnattachedMedia {
|
||||||
id: string;
|
id: string;
|
||||||
pukey: string;
|
pukey: string;
|
||||||
cid: string;
|
url: string;
|
||||||
data: {
|
data: {
|
||||||
name?: string;
|
name?: string;
|
||||||
mime?: string;
|
mime?: string;
|
||||||
|
|
Loading…
Reference in New Issue