From 19f5e5c14dd2cd54e7c58980a0740f2c820b9367 Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 1 Aug 2022 05:17:32 +0000 Subject: [PATCH] Get mentions from content FossilOrigin-Name: 29716d4f981e4cc8750de01a82dea395044c472165ede67954ac7cc781c3532d --- perl/string_helpers.pm | 13 +++++++++++-- src/reply.c | 2 +- templates/postbox.tt | 6 +----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/perl/string_helpers.pm b/perl/string_helpers.pm index 7f3399d..622f51c 100644 --- a/perl/string_helpers.pm +++ b/perl/string_helpers.pm @@ -50,7 +50,16 @@ sub format_username sub get_mentions_from_content { - my $status = shift; + my ($ssn, $status) = @_; + my $result = ''; + my $acct; # todo - ""; + while ($status->{'content'} =~ + /@(?:)?.*?(?:<\/span>)?/gs) + { + $acct = $2 . '@' . $1; + $result .= '@' . $acct . ' ' if $ssn->{account}->{acct} eq $acct; + } + ($status->{account}->{acct} eq $ssn->{account}->{acct}) + ? $result : '@' . $status->{account}->{acct} . ' ' . $result; } diff --git a/src/reply.c b/src/reply.c index 7203cde..2e9dc0b 100644 --- a/src/reply.c +++ b/src/reply.c @@ -75,7 +75,7 @@ char* construct_post_box(struct mstdnt_status* reply_status, * so we just grep for regex href * - Misskey/Mastodon adds an @ symbol in the href param, while pleroma adds /users and honk adds /u */ -#define REGEX_REPLY "@(?:)?.*?(?:<\\/span>)?" +#define REGEX_REPLY "" char* reply_status(struct session* ssn, char* id, struct mstdnt_status* status) { diff --git a/templates/postbox.tt b/templates/postbox.tt index 83f274e..46b4c06 100644 --- a/templates/postbox.tt +++ b/templates/postbox.tt @@ -3,11 +3,7 @@ [% END %]
- +