-
-
Notifications
You must be signed in to change notification settings - Fork 948
Add hashing for activity ids #6366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 16 commits
7cf9223
36f48fe
b4bab81
a9f4195
91f043f
b6a25e9
0a619de
99d0782
5ae79aa
ef854ef
73db584
f2d4584
5a72720
de6b70c
2205372
b7ac661
f1b062f
3195399
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,21 @@ impl CreateOrUpdateNote { | |
| .await? | ||
| .into(); | ||
|
|
||
| let id = generate_activity_id(kind.clone(), &context)?; | ||
| // get object_id for activity id generation | ||
| let ap_id = (*comment.ap_id.0).clone(); | ||
| let object_id = match kind { | ||
| // for Create, use the comment's ap id | ||
| CreateOrUpdateType::Create => Some(&ap_id), | ||
| // for Update, use a timestamp to ensure each Update activity is unique | ||
| CreateOrUpdateType::Update => { | ||
| let timestamp = comment.updated_at.unwrap_or(comment.published_at); // use the latest timestamp | ||
| let mut seed_url = ap_id; | ||
| seed_url.set_fragment(Some(×tamp.to_rfc3339())); | ||
|
Comment on lines
+65
to
+67
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't need to be in this PR, but these things should be trait functions. Actors have a There's no reason why that couldn't also be done for the other types, and activities on them also. |
||
| Some(&seed_url.clone()) | ||
| } | ||
| }; | ||
|
|
||
| let id = generate_activity_id(kind.clone(), object_id, &context)?; | ||
| let note = ApubComment(comment).into_json(&context).await?; | ||
|
|
||
| let create_or_update = CreateOrUpdateNote { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,10 @@ impl CreateOrUpdatePage { | |
| actor: &ApubPerson, | ||
| community: &ApubCommunity, | ||
| kind: CreateOrUpdateType, | ||
| object_id: Option<&Url>, | ||
| context: &Data<LemmyContext>, | ||
| ) -> LemmyResult<CreateOrUpdatePage> { | ||
| let id = generate_activity_id(kind.clone(), context)?; | ||
| let id = generate_activity_id(kind.clone(), object_id, context)?; | ||
| Ok(CreateOrUpdatePage { | ||
| actor: actor.id().clone().into(), | ||
| to: generate_to(community)?, | ||
|
|
@@ -70,8 +71,22 @@ impl CreateOrUpdatePage { | |
| .await? | ||
| .into(); | ||
|
|
||
| // get object_id for activity id generation | ||
| let ap_id = (*post.ap_id.0).clone(); | ||
| let object_id = match kind { | ||
| // for Create, use the post's ap id | ||
| CreateOrUpdateType::Create => Some(&ap_id), | ||
| // for Update, use a timestamp to ensure each Update activity is unique | ||
| CreateOrUpdateType::Update => { | ||
| let timestamp = post.updated_at.unwrap_or(post.published_at); // use the latest timestamp | ||
| let mut seed_url = ap_id; | ||
| seed_url.set_fragment(Some(×tamp.to_rfc3339())); | ||
| Some(&seed_url.clone()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| } | ||
| }; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Private message also needs the same logic. Best And you dont need to change anything in this file, it only needs to be in |
||
|
|
||
| let create_or_update = | ||
| CreateOrUpdatePage::new(post.into(), &person, &community, kind, &context).await?; | ||
| CreateOrUpdatePage::new(post.into(), &person, &community, kind, object_id, &context).await?; | ||
| let inboxes = tagged_user_inboxes(&create_or_update.object.tag, &context).await?; | ||
| let activity = AnnouncableActivities::CreateOrUpdatePost(create_or_update); | ||
| send_activity_in_community(activity, &person, &community, inboxes, false, &context).await?; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we want the activity id for
Announceactivities to be the hash in the outbox, and a random UUID in thesent_activitytable? ForCreateactivities, both are the same.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same activity must always have the same ID.