Add fedaration to tags, allow tags to be added to statuses

master
teknomunk 11 months ago
parent ea19e6eefc
commit 406c64ea10

@ -325,6 +325,18 @@ struct ap_object* activity_create_Note( struct status* s )
array_append( &act->tags, sizeof(tag), &tag );
}
for( int i = 0; i < s->tags.count; ++i ) {
struct ap_activity_tag* tag;
tag = malloc(sizeof(*tag));
memset(tag,0,sizeof(*tag));
tag->type = aptag_hashtag;
tag->name = aformat("#%s", s->tags.items[i] );
tag->href = aformat( "https://%s/tag/%s", g_server->domain, s->tags.items[i] );
array_append( &act->tags, sizeof(tag), &tag );
}
str = aformat( "https://%s/owner/followers", g_server->domain );
array_append( &act->cc, sizeof(str), &str );

@ -242,6 +242,20 @@ void status_add_mention( struct status* s, int id )
array_append( &s->mentions, sizeof(id), &id );
}
void status_add_tag( struct status* s, const char* tag )
{
if( !tag ) { return; }
for( int i = 0; i < s->tags.count; ++i ) {
if( 0 == strcmp( s->tags.items[i], tag ) ) {
// Tag already present, don't add a second time
return;
}
}
char* value = strdup(tag);
array_append( &s->tags, sizeof(value), &value );
}
void status_add_repost( struct status* s, struct status* repost )
{
if( repost->id == 0 ) { return; }

@ -115,6 +115,7 @@ void status_add_to_timeline( struct status* s, int timeline_id );
void status_get_context( struct status* s, void* ancestors, void* replies );
void status_add_mention( struct status* s, int id );
void status_add_tag( struct status* s, const char* tag );
void status_add_repost( struct status* s, struct status* repost );
void status_add_quote( struct status* s, struct status* quote );
void status_make_reply_to( struct status* s, int in_reply_to );

@ -46,6 +46,21 @@ char* status_render_source( struct status* s, const char* default_server )
fprintf( f, "<a href='%s' rel='ugc'>%s</a>", url, url );
free(url);
} else if( isalpha(i[1]) && *i == '#' ) {
i += 1;
char* start = i;
while( *i && ( isalpha(*i) || *i == '_' || *i == '-' ) ) ++i;
char* tag = strndup( start, i - start );
printf( "tag = %s\n", tag );
fprintf( f, "<a class=\"hashtag\" data-tag=\"%s\" href=\"https://%s/tag/%s\" rel=\"tag ugc\">#%s</a>",
tag, default_server, tag, tag
);
status_add_tag( s, tag );
free(tag);
} else if( isalpha(i[1]) && *i == '@' ) {
char* start = i;
while( *i && !index(" ,\r\n",*i) ) ++i;

Loading…
Cancel
Save