mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-27 08:16:12 +00:00
Accept comments with hashtags from Friendica
This commit is contained in:
parent
2e01e8e42c
commit
a26ba84482
70
crates/apub/assets/friendica/objects/note_2.json
Normal file
70
crates/apub/assets/friendica/objects/note_2.json
Normal file
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"vcard": "http://www.w3.org/2006/vcard/ns#",
|
||||
"dfrn": "http://purl.org/macgirvin/dfrn/1.0/",
|
||||
"diaspora": "https://diasporafoundation.org/ns/",
|
||||
"litepub": "http://litepub.social/ns#",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"schema": "http://schema.org#",
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"sensitive": "as:sensitive",
|
||||
"Hashtag": "as:Hashtag",
|
||||
"directMessage": "litepub:directMessage",
|
||||
"discoverable": "toot:discoverable",
|
||||
"PropertyValue": "schema:PropertyValue",
|
||||
"value": "schema:value"
|
||||
}
|
||||
],
|
||||
"id": "https://nerdica.net/objects/a85d7459-7262-66e9-f901-f05552414769",
|
||||
"type": "Note",
|
||||
"summary": "",
|
||||
"inReplyTo": "https://lemmy.ml/comment/167904",
|
||||
"diaspora:guid": "a85d7459-7262-66e9-f901-f05552414769",
|
||||
"published": "2022-04-25T18:35:37Z",
|
||||
"url": "https://nerdica.net/display/a85d7459-7262-66e9-f901-f05552414769",
|
||||
"attributedTo": "https://nerdica.net/profile/liwott",
|
||||
"sensitive": false,
|
||||
"context": "https://lemmy.ml/post/243881#context",
|
||||
"content": "Note that on <a href=\"https://nerdica.net/search?tag=Friendica\" class=\"mention hashtag\" rel=\"tag\">#<span>Friendica</span></a> we canquote-share, and we can also do it in comments. As I discovered recently by playing in the below post<br><div><a href=\"https://lemmy.ml/post/241819\">♲</a> @<span class=\"vcard\"><a href=\"https://lemmy.ml/u/Liwott\" class=\"url u-url mention\" title=\"Liwott@lemmy.ml\"><span class=\"fn nickname mention\">Liwott@lemmy.ml</span></a>:</span><blockquote><h3>Do your commenting tests here.</h3><br>While posting tests can obsviously be made on this community without further precision, commenting requires a post to comment on. This is what this post is for.</blockquote></div>\nthese make it through to <a href=\"https://nerdica.net/search?tag=Lemmy\" class=\"mention hashtag\" rel=\"tag\">#<span>Lemmy</span></a> when we do it in a comment, but not in a top-level post (which is already a great start !). So, in Friendica, all that's missing is the backlink !<blockquote>Also the Linked Data nature of the underlying data would make it possible to create all different kinds of associations, not just a plain cross-ref link.</blockquote>This seems interesting, but I must say I don't directly see an application of this in the context of microblogging/commenting. Maybe you can inspire us here? 😀",
|
||||
"contentMap": {
|
||||
"en": "Note that on #<a href=\"https://nerdica.net/search?tag=Friendica\" class=\"tag\" rel=\"tag\" title=\"Friendica\">Friendica</a> we can quote-share, and we can also do it in comments. As I discovered recently by playing in the below post<br>\n<div class=\"shared-wrapper well well-sm\">\n\t<div class=\"shared_header\">\n\t\t\t\t\t<a href=\"https://lemmy.ml/u/Liwott\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"avatar shared-userinfo\">\n\t\t\t\t<img src=\"https://nerdica.net/photo/contact/80/44b525e5e979775f3ab2722747f7f07704134945?ts=1644399345\" alt=\"\">\n\t\t\t</a>\n\t\t\t\t<div class=\"metadata\">\n\t\t\t<p class=\"shared-author\">\n\t\t\t\t<a href=\"https://lemmy.ml/u/Liwott\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"shared-wall-item-name\">\n\t\t\t\t\tLiwott\n\t\t\t\t</a>\n\t\t\t</p>\n\t\t\t<p class=\"shared-wall-item-ago\">\n\t\t\t\t\t\t\t\t<a href=\"/display/44b525e5-4101b003e005e70a-d472d963\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"shared-time\">2022-04-23 14:34:19</span>\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t</p>\n\t\t</div>\n\t\t<div class=\"preferences\">\n\t\t\t\t\t\t\t<span class=\"wall-item-network\"><i class=\"fa fa-activitypub\" title=\"lemmy (AP)\"></i></span>\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://lemmy.ml/post/241819\" class=\"plink u-url\" title=\"Link to source\">\n\t\t\t\t\t<i class=\"fa fa-external-link\"></i>\n\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t</div>\n\t<blockquote class=\"shared_content\" dir=\"auto\"><br class=\"top-anchor\"><h3>Do your commenting tests here.</h3><br>While posting tests can obsviously be made on this community without further precision, commenting requires a post to comment on. This is what this post is for.<br class=\"button-anchor\"></blockquote>\n</div>\nthese make it through to #<a href=\"https://nerdica.net/search?tag=Lemmy\" class=\"tag\" rel=\"tag\" title=\"Lemmy\">Lemmy</a> when we do it in a comment, but not in a top-level post (which is already a great start !). So, in Friendica, all that's missing is the backlink !<blockquote>Also the Linked Data nature of the underlying data would make it possible to createall different kinds of associations, not just a plain cross-ref link.</blockquote>This seems interesting, but I must say I don't directly see an application of this in the context of microblogging/commenting. Maybe you can inspire us here? 😀"
|
||||
},
|
||||
"source": {
|
||||
"content": "Note that on #[url=https://nerdica.net/search?tag=Friendica]Friendica[/url] we can quote-share, and we can also do it in comments. As I discovered recently by playing in the below post\n[share author='Liwott' profile='https://lemmy.ml/u/Liwott' avatar='' link='https://lemmy.ml/post/241819' posted='2022-04-23 14:34:19' guid='44b525e5-4101b003e005e70a-d472d963'][h3]Do your commenting tests here.[/h3]\nWhile posting tests can obsviously bemade on this community without further precision, commenting requires a post to comment on. This is what this post is for.[/share]\nthese make it through to #[url=https://nerdica.net/search?tag=Lemmy]Lemmy[/url] when we do it in a comment, but not in a top-level post (which is already a great start !).So, in Friendica, all that's missing is the backlink !\n[quote]Also the Linked Data nature of the underlying data would make it possible to create all different kinds of associations, not just a plain cross-ref link.[/quote]\nThis seems interesting, but I must say I don't directly see an application ofthis in the context of microblogging/commenting. Maybe you can inspire us here? :)",
|
||||
"mediaType": "text/bbcode"
|
||||
},
|
||||
"diaspora:comment": "{\"author\":\"liwott@nerdica.net\",\"guid\":\"a85d7459-7262-66e9-f901-f05552414769\",\"created_at\":\"2022-04-25T18:35:37Z\",\"edited_at\":\"2022-04-25T18:35:37Z\",\"parent_guid\":\"44b525e5-532e8d03ea8f5dff-c45ad734\",\"text\":\"Note that on #Friendica we can quote-share, and we can also do it in comments. As I discovered recently by playing in the below post\\n\\n- - - - - -\\n\\n**\\u2672 [Liwott](https:\\/\\/lemmy.ml\\/u\\/Liwott)** - [2022-04-23 14:34:19 GMT](https:\\/\\/lemmy.ml\\/post\\/241819)\\n\\n> ### Do your commenting tests here.\\n> \\n> \\n> While posting tests can obsviously be made on this community without further precision, commenting requires a post to comment on. This is what this post is for.\\n\\nthese make it through to #Lemmy when we do it in a comment, but not in a top-level post (which is already a great start !). So, in Friendica, all that's missingis the backlink !> Also the Linked Data nature of the underlying data would make it possible to create all different kinds of associations, not just a plain cross-ref link.\\n\\nThis seems interesting, but I must say I don't directly see an application of this in the context of microblogging\\/commenting. Maybe you can inspire us here? \\ud83d\\ude00\",\"author_signature\":\"Ho9NYtWzEkREWyvyjUnUOuYvPBI35I4SGAb+cXBMp\\/n2Tu5gJipmKuIcMpyrxYNtIqXRwr\\/BUOGkd99s5\\/uBWCcL8jCbx3i4wTVYzdgPAZaykd7EqdwULNRTtf8eKL2Wvdo7tYtYm\\/Yo5dajM5HI2NuOgQR8CgLInmEmBlKLZ8EkzAC+z2EwMhx7JBmKzeEabAmclJgR8IfYWX34KPYqBFcZ9w8V\\/D3lcPGs3olJcvwqHSnY7vgL1X9f2XVAQ38pmGg2ggaKhKa5QligOhkPC57NYPh\\/1SR9Plpyf0QPQRCuCs5vkEloe47rxaWZ62gfKqul0dXmGchIcIYhms4DN7DaGapOXaQPuIfh4FIvEb9qh9mJ7haHa9+0uD9TUToG+wilifdtGwZoZnF9zMfGSLiaDlD\\/UZHA1jXMa3uhfGE+MUT1dnJcZqfE+jwJUb4BPuYxTm7UClvERg8sfDFWqlMaNpPtJlay2PL\\/nwCxuQ54M5v6lgyb8NylIrjFyUttiBnNC6HYsy4YoPnN7r\\/0EV3Av1KtnJt84xrJbDo4fvR1TPs4Hmx5BoH1cvHCH2Tld2OgKUCHd5g9Pr3RVPEGGillZSqDWCP6317BQ0EDftTwABjPXoitQX2ZaHXXqXLWCRoLk6MsEWM0jsoGzv+GP4coZWreCD1XRI5an1W4998=\",\"thread_parent_guid\":\"44b525e5-cb6ed8649810a557-1ccd7106\"}",
|
||||
"attachment": [],
|
||||
"tag": [
|
||||
{
|
||||
"type": "Hashtag",
|
||||
"href": "https://nerdica.net/search?tag=Friendica",
|
||||
"name": "#Friendica"
|
||||
},
|
||||
{
|
||||
"type": "Hashtag",
|
||||
"href": "https://nerdica.net/search?tag=Lemmy",
|
||||
"name": "#Lemmy"
|
||||
},
|
||||
{
|
||||
"type": "Mention",
|
||||
"href": "https://lemmy.ml/u/Liwott",
|
||||
"name": "@Liwott@lemmy.ml"
|
||||
}
|
||||
],
|
||||
"to": [
|
||||
"https://lemmy.ml/u/humanetech",
|
||||
"https://www.w3.org/ns/activitystreams#Public",
|
||||
"https://lemmy.ml/c/fediversefutures"
|
||||
],
|
||||
"cc": [
|
||||
"https://lemmy.ml/u/Liwott",
|
||||
"https://nerdica.net/followers/liwott",
|
||||
"https://lemmy.ml/u/poVoq",
|
||||
"https://mastodon.social/users/humanetech",
|
||||
"https://lemmy.ml/u/KelsonV"
|
||||
]
|
||||
}
|
|
@ -9,6 +9,7 @@ use crate::{
|
|||
verify_person_in_community,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
mentions::MentionOrValue,
|
||||
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::{create_or_update::comment::CreateOrUpdateComment, CreateOrUpdateType},
|
||||
};
|
||||
|
@ -70,6 +71,13 @@ impl CreateOrUpdateComment {
|
|||
let tagged_users: Vec<ObjectId<ApubPerson>> = create_or_update
|
||||
.tag
|
||||
.iter()
|
||||
.filter_map(|t| {
|
||||
if let MentionOrValue::Mention(t) = t {
|
||||
Some(t)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.map(|t| t.href.clone())
|
||||
.map(ObjectId::new)
|
||||
.collect();
|
||||
|
|
|
@ -16,8 +16,16 @@ use lemmy_utils::{
|
|||
};
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum MentionOrValue {
|
||||
Mention(Mention),
|
||||
Value(Value),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Mention {
|
||||
pub href: Url,
|
||||
|
@ -28,7 +36,7 @@ pub struct Mention {
|
|||
|
||||
pub struct MentionsAndAddresses {
|
||||
pub ccs: Vec<Url>,
|
||||
pub tags: Vec<Mention>,
|
||||
pub tags: Vec<MentionOrValue>,
|
||||
}
|
||||
|
||||
/// This takes a comment, and builds a list of to_addresses, inboxes,
|
||||
|
@ -81,6 +89,7 @@ pub async fn collect_non_local_mentions(
|
|||
}
|
||||
}
|
||||
|
||||
let tags = tags.into_iter().map(MentionOrValue::Mention).collect();
|
||||
Ok(MentionsAndAddresses {
|
||||
ccs: addressed_ccs,
|
||||
tags,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
mentions::Mention,
|
||||
mentions::MentionOrValue,
|
||||
objects::person::ApubPerson,
|
||||
protocol::{activities::CreateOrUpdateType, objects::note::Note, Unparsed},
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ pub struct CreateOrUpdateComment {
|
|||
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(default)]
|
||||
pub(crate) tag: Vec<Mention>,
|
||||
pub(crate) tag: Vec<MentionOrValue>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: CreateOrUpdateType,
|
||||
pub(crate) id: Url,
|
||||
|
|
|
@ -75,7 +75,8 @@ mod tests {
|
|||
test_json::<Person>("assets/friendica/objects/person_2.json").unwrap();
|
||||
test_json::<Page>("assets/friendica/objects/page_1.json").unwrap();
|
||||
test_json::<Page>("assets/friendica/objects/page_2.json").unwrap();
|
||||
test_json::<Note>("assets/friendica/objects/note.json").unwrap();
|
||||
test_json::<Note>("assets/friendica/objects/note_1.json").unwrap();
|
||||
test_json::<Note>("assets/friendica/objects/note_2.json").unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
mentions::Mention,
|
||||
mentions::MentionOrValue,
|
||||
objects::{comment::ApubComment, person::ApubPerson, post::ApubPost},
|
||||
protocol::Source,
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ pub struct Note {
|
|||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
#[serde(default)]
|
||||
pub(crate) tag: Vec<Mention>,
|
||||
pub(crate) tag: Vec<MentionOrValue>,
|
||||
}
|
||||
|
||||
impl Note {
|
||||
|
|
Loading…
Reference in a new issue