Remove repeated mention tags when processing activities
This commit is contained in:
parent
be2201f7b6
commit
82fe25d458
2 changed files with 16 additions and 12 deletions
|
@ -229,9 +229,7 @@ pub async fn process_note(
|
|||
let mut mentions: Vec<Uuid> = Vec::new();
|
||||
if let Some(list) = object.tag {
|
||||
for tag in list {
|
||||
if tag.tag_type != MENTION {
|
||||
continue;
|
||||
};
|
||||
if tag.tag_type == MENTION {
|
||||
if let Some(href) = tag.href {
|
||||
let profile = get_or_fetch_profile_by_actor_id(
|
||||
db_client,
|
||||
|
@ -239,10 +237,13 @@ pub async fn process_note(
|
|||
&href,
|
||||
&config.media_dir(),
|
||||
).await?;
|
||||
if !mentions.contains(&profile.id) {
|
||||
mentions.push(profile.id);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
let in_reply_to_id = match object.in_reply_to {
|
||||
Some(object_id) => {
|
||||
match parse_object_id(&instance.url(), &object_id) {
|
||||
|
|
|
@ -26,8 +26,10 @@ fn find_mentions(
|
|||
let mut mentions = vec![];
|
||||
for caps in mention_re.captures_iter(text) {
|
||||
let acct = pattern_to_acct(&caps, instance_host);
|
||||
if !mentions.contains(&acct) {
|
||||
mentions.push(acct);
|
||||
};
|
||||
};
|
||||
mentions
|
||||
}
|
||||
|
||||
|
@ -87,6 +89,7 @@ mod tests {
|
|||
"@@invalid@server2.com ",
|
||||
"@test@server3.com@nospace@server4.com ",
|
||||
"@notmention ",
|
||||
"@user2@server2.com copy ",
|
||||
"some text",
|
||||
);
|
||||
let results = find_mentions(INSTANCE_HOST, text);
|
||||
|
|
Loading…
Reference in a new issue