Add reblog notifications (not actually working, it seems), ignore Join activities

master
teknomunk 1 year ago
parent 3aa19cde4e
commit 6b05a6e553

@ -502,6 +502,7 @@ bool route_activity( struct ap_object* act )
case ap_Move: return route_move(act);
case ap_Block: return route_block(act);
case ap_Remove: return true;
case ap_Join: return true;
default:
printf( "Unhandled activity type: %d\n", act->type );
}

@ -6,6 +6,7 @@
// Model
#include "model/account.h"
#include "model/status.h"
#include "model/notification.h"
// Standard Library
#include <string.h>
@ -59,6 +60,14 @@ bool route_announce( struct ap_object* act )
s->account_id = actor_account->id;
s->sensitive = act->sensitive;
if( original_post->account_id == owner_account_id ) {
struct notification* note = notification_new();
note->type = nt_reblog;
note->status_id = s->id;
note->account_id = actor_account->id;
note->created_at = time(NULL);
}
status_save_new(s);
status_add_to_timeline( original_post, original_post->account_id );

@ -92,7 +92,7 @@ static bool process_envelope( struct outbox_envelope* env )
);
char user_agent[512];
snprintf( user_agent, sizeof(user_agent), "User-Agent: curl (Apogee/0.1; +https://%s/)", g_server->domain );
snprintf( user_agent, sizeof(user_agent), "User-Agent: curl (Apogee/0.1; +https://%s/owner/actor)", g_server->domain );
char digest_header[512];
snprintf( digest_header, sizeof(digest_header), "Digest: %s", hs.digest );

@ -23,6 +23,7 @@ static struct json_enum notification_type_enum[] = {
{ "like", nt_like },
{ "react", nt_react },
{ "move", nt_move },
{ "reblog", nt_reblog },
{ NULL, -1 },
};
@ -32,6 +33,7 @@ static struct json_object_field notification_layout[] = {
JSON_FIELD_INTEGER( account_id, true ),
JSON_FIELD_INTEGER( status_id, false ),
JSON_FIELD_INTEGER( ref_account_id, false ),
JSON_FIELD_INTEGER( move_target_account_id, false ),
JSON_FIELD_DATETIME( created_at, false ),
JSON_FIELD_STRING( react, false ),
JSON_FIELD_ENUM( type, notification_type_enum, true ),

@ -14,6 +14,7 @@ struct notification
int status_id;
struct status* system_status;
int ref_account_id;
int move_target_account_id;
time_t created_at;
bool is_muted;
bool is_seen;
@ -32,6 +33,7 @@ enum notification_type
nt_like = 6,
nt_react = 7,
nt_move = 8,
nt_reblog = 9,
};
struct notification* notification_from_id( int id );

@ -50,28 +50,34 @@ char* status_render_source( struct status* s )
while( *i && !index(" ,\r\n",*i) ) ++i;
char* handle = strndup( start, i - start );
struct account* user = account_from_webfinger( &handle[1] );
if( !user ) {
char buffer[512];
format( buffer, 512, "%s@%s", handle, account_server );
user = account_from_webfinger( &handle[1] );
}
if( user ) {
status_add_mention( s, user->id );
fprintf( f,
"<span class='h-card'>"
"<a class='u-url mention' href='%s' rel='ugc'>"
"@<span>%s</span>"
"</a>"
"</span>",
user->account_url, user->handle
);
account_free(user);
/*
if( strstr( handle, "mostr.pub" ) ) {
fprintf( f, "<a href='https://mostr.pub/%s'>@%.4s@nostr</a>", handle, handle );
} else {
fprintf( f, "%s", handle );
}
*/
struct account* user = account_from_webfinger( &handle[1] );
if( !user ) {
char buffer[512];
format( buffer, 512, "%s@%s", handle, account_server );
user = account_from_webfinger( &handle[1] );
}
if( user ) {
status_add_mention( s, user->id );
fprintf( f,
"<span class='h-card'>"
"<a class='u-url mention' href='%s' rel='ugc'>"
"@<span>%s</span>"
"</a>"
"</span>",
user->account_url, user->handle
);
account_free(user);
} else {
fprintf( f, "%s", handle );
}
//}
free(handle);
} else if( *i == ':' ) {
// Emoji

@ -20,6 +20,7 @@ static struct json_enum type_enum[] = {
{ "mention", nt_block },
{ "mention", nt_mention },
{ "move", nt_move },
{ "reblog", nt_reblog },
{ "pleroma:emoji_reaction", nt_react },
{ NULL, 0 },
@ -37,6 +38,12 @@ static struct json_object_field api_Notification_layout[] = {
.offset = offsetof( OBJ_TYPE, account_id ),
.type = &api_Account_type,
},
{
.key = "target",
.required = false,
.offset = offsetof( OBJ_TYPE, move_target_account_id ),
.type = &api_Account_type,
},
JSON_FIELD_DATETIME( created_at, true ),
{
.key = "id",

Loading…
Cancel
Save