Conversation
|
|
||
| let mut ordered_items = vec![]; | ||
| for post_view in post_views { | ||
| let post_ap_id = post_view.post.ap_id.clone(); |
There was a problem hiding this comment.
This is the only place where I am passing in the object_id. I think it makes the ids for Announce and Create stable. Not sure where else I could use it.
There was a problem hiding this comment.
Also needs to be in crates/apub/activities/src/create_or_update/post.rs so both code paths generate the same id.
| enum_delegate = "0.2.0" | ||
| either = { workspace = true } | ||
| lemmy_diesel_utils = { workspace = true } | ||
| md5 = "0.8.0" |
There was a problem hiding this comment.
Use sha2 which we are already using as dependency.
|
|
||
| let create_or_update = | ||
| CreateOrUpdatePage::new(post.into(), &person, &community, kind, &context).await?; | ||
| CreateOrUpdatePage::new(post.into(), &person, &community, kind, None, &context).await?; |
There was a problem hiding this comment.
| CreateOrUpdatePage::new(post.into(), &person, &community, kind, None, &context).await?; | |
| CreateOrUpdatePage::new(post.into(), &person, &community, kind, Some(post.ap_id), &context).await?; |
There was a problem hiding this comment.
Actually this can be a problem when editing the post, then each Update activity will have the same id. So you also need to hash the timestamp (published_at or updated_at).
| .into(); | ||
|
|
||
| let id = generate_activity_id(kind.clone(), &context)?; | ||
| let id = generate_activity_id(kind.clone(), None, &context)?; |
There was a problem hiding this comment.
| let id = generate_activity_id(kind.clone(), None, &context)?; | |
| let id = generate_activity_id(kind.clone(), Some(comment.ap_id), &context)?; |
| fn generate_activity_id<T>(kind: T, context: &LemmyContext) -> Result<Url, ParseError> | ||
| fn generate_activity_id<T>( | ||
| kind: T, | ||
| object_id: Option<&str>, |
There was a problem hiding this comment.
| object_id: Option<&str>, | |
| object_id: Option<&Url>, |
| /// Generate a unique ID for an activity, in the format: | ||
| /// `http(s)://example.com/receive/create/202daf0a-1489-45df-8d2e-c8a3173fed36` | ||
| fn generate_activity_id<T>(kind: T, context: &LemmyContext) -> Result<Url, ParseError> | ||
| fn generate_activity_id<T>( |
There was a problem hiding this comment.
To avoid passing None in so many places, you could do:
fn generate_activity_id_with_object_id(kind, context) {
generate_activity_id(kind, None, context)
}
fn generate_activity_id(kind, object_id, context) {
generate_activity_id(kind, context)
}
For issue #6341.
Add hashing for activity ids so that the ids of the activity objects do not change on every request.