@ -2,6 +2,7 @@
# include "status.h"
# include "status/react.h"
# include "model/server.h"
# include "model/account.h"
# include "model/ap/activity.h"
# include "model/notification.h"
@ -79,6 +80,10 @@ struct status* status_from_id( unsigned int id )
s - > source = strdup ( " " ) ;
}
if ( ! s - > remote & & ! s - > url ) {
s - > url = aformat ( " https://%s/note/%d " , g_server_name , s - > id ) ;
}
return s ;
}
struct status * status_new_repost ( struct status * s , struct account * a )
@ -94,8 +99,32 @@ struct status* status_new_repost( struct status* s, struct account* a )
status_save_new ( repost ) ;
return repost ;
}
static struct status * status_from_local_uri ( const char * uri )
{
if ( 0 ! = strncmp ( " https:// " , uri , 8 ) ) { return NULL ; }
uri + = 8 ;
int server_name_length = strlen ( g_server_name ) ;
if ( 0 ! = strncmp ( g_server_name , uri , server_name_length ) ) { return NULL ; }
uri + = server_name_length ;
if ( 0 ! = strncmp ( " /note/ " , uri , 6 ) ) { return NULL ; }
uri + = 6 ;
// Note: zero is never a valid status id
int id = atoi ( uri ) ;
if ( id = = 0 ) { return NULL ; }
return status_from_id ( id ) ;
}
struct status * status_from_uri ( const char * uri )
{
// Check for local
struct status * s = status_from_local_uri ( uri ) ;
if ( s ) { return s ; }
int id = - 1 ;
if ( ! hash_index_get ( " data/statuses/uri " , uri , & id ) ) { return NULL ; }