|
|
|
@ -13,6 +13,7 @@
|
|
|
|
|
#include "json/json.h"
|
|
|
|
|
#include "json/layout.h"
|
|
|
|
|
#include "ffdb/hash_index.h"
|
|
|
|
|
#include "ffdb/trie.h"
|
|
|
|
|
#include "sha256/sha256.h"
|
|
|
|
|
#include "collections/array.h"
|
|
|
|
|
#include "http/client/client.h"
|
|
|
|
@ -35,6 +36,7 @@ static struct json_object_field status_layout[] = {
|
|
|
|
|
JSON_FIELD_STRING( content, false ),
|
|
|
|
|
JSON_FIELD_STRING( source, false ),
|
|
|
|
|
JSON_FIELD_BOOL( pinned, false ),
|
|
|
|
|
JSON_FIELD_BOOL( bookmarked, false ),
|
|
|
|
|
JSON_FIELD_DATETIME( published, false ),
|
|
|
|
|
|
|
|
|
|
JSON_FIELD_INTEGER( in_reply_to, false ),
|
|
|
|
@ -170,6 +172,8 @@ struct status* status_from_uri( const char* uri )
|
|
|
|
|
}
|
|
|
|
|
void status_add_reply( struct status* s, struct status* child )
|
|
|
|
|
{
|
|
|
|
|
if( child->id == 0 ) { return; }
|
|
|
|
|
|
|
|
|
|
bool is_already_parent_reply = false;
|
|
|
|
|
for( int i = 0; i < s->replies.count; ++i ) {
|
|
|
|
|
if( s->replies.items[i] == child->id ) {
|
|
|
|
@ -746,4 +750,48 @@ void status_add_like( struct status* s, struct account* a )
|
|
|
|
|
|
|
|
|
|
status_save(s);
|
|
|
|
|
}
|
|
|
|
|
void status_set_bookmark( struct status* s )
|
|
|
|
|
{
|
|
|
|
|
s->bookmarked = true;
|
|
|
|
|
mkdir( "data/bookmarks", 0755 );
|
|
|
|
|
char key[32];
|
|
|
|
|
ffdb_trie_set( "data/owner/bookmarks", format(key,32,"%d",s->id), "T" );
|
|
|
|
|
status_save(s);
|
|
|
|
|
}
|
|
|
|
|
void status_clear_bookmark( struct status* s )
|
|
|
|
|
{
|
|
|
|
|
s->bookmarked = false;
|
|
|
|
|
mkdir( "data/bookmarks", 0755 );
|
|
|
|
|
char key[32];
|
|
|
|
|
ffdb_trie_set( "data/owner/bookmarks", format(key,32,"%d",s->id), NULL );
|
|
|
|
|
status_save(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void status_get_bookmarks( int offset, int limit, void* results_ptr )
|
|
|
|
|
{
|
|
|
|
|
struct {
|
|
|
|
|
char** items;
|
|
|
|
|
int count;
|
|
|
|
|
} keys;
|
|
|
|
|
memset( &keys, 0, sizeof(keys) );
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct status** items;
|
|
|
|
|
int count;
|
|
|
|
|
} *results = results_ptr;
|
|
|
|
|
results->count = 0;
|
|
|
|
|
|
|
|
|
|
ffdb_trie_list( "data/owner/bookmarks", offset, limit, &keys, NULL );
|
|
|
|
|
for( int i = 0; i < keys.count; ++i ) {
|
|
|
|
|
int id;
|
|
|
|
|
if( 1 == sscanf( keys.items[i], "%d", &id ) ) {
|
|
|
|
|
struct status* s = status_from_id(id);
|
|
|
|
|
if( s ) {
|
|
|
|
|
array_append( results_ptr, sizeof(s), &s );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free( keys.items[i] );
|
|
|
|
|
}
|
|
|
|
|
free( keys.items );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|