Fix media posts

master
teknomunk 1 year ago
parent ea1bcff61b
commit 0bfecc9929

@ -136,9 +136,7 @@ bool handle_post( struct http_request* req, struct account* a )
struct media* m = media_from_id( atoi(params.media_ids.items[i]) );
if( !m ) { continue; }
char* url = aformat( "https://%s/media/%d/blob", g_server->domain, m->id );
array_append( &s->media, sizeof(url), &url );
media_free(m);
array_append( &s->media2, sizeof(m), &m );
}
if( params.in_reply_to_id ) {

@ -158,6 +158,8 @@ bool handle_media( struct http_request* req )
m = malloc(sizeof(*m));
memset(m,0,sizeof(*m));
m->id = id;
m->remote_url = aformat( "https://%s/media/%d/blob", g_server->domain, id );
m->preview_url = aformat( "https://%s/media/%d/preview", g_server->domain, id );
f = fopen(format(filename,sizeof(filename), "data/media/%d.blob",id), "w" );
if( !http_request_write_multipart_to_FILE( req, f, &m->content_type ) ) { goto failed; }

@ -292,21 +292,19 @@ struct ap_object* activity_create_Note( struct status* s )
char* str = strdup("https://www.w3.org/ns/activitystreams#Public");
array_append( &act->to, sizeof(str), &str );
for( int i = 0; i < s->media.count; ++i ) {
struct media* m = media_from_local_uri( s->media.items[i] );
if( m ) {
struct ap_object* att;
att = malloc(sizeof(*att));
memset(att,0,sizeof(*att));
att->type = ap_Document;
att->url = strdup(s->media.items[i]);
att->media_type = strdup(m->content_type);
att->name = strdup("");
array_append( &act->attachments, sizeof(att), &att );
}
media_free(m);
for( int i = 0; i < s->media2.count; ++i ) {
struct media* m = s->media2.items[i];
struct ap_object* att;
att = malloc(sizeof(*att));
memset(att,0,sizeof(*att));
att->type = ap_Document;
att->url = strdup(m->remote_url);
att->media_type = strdup(m->content_type);
att->name = strdup("");
array_append( &act->attachments, sizeof(att), &att );
}
for( int i = 0; i < s->emoji.count; ++i ) {

Loading…
Cancel
Save