forked from alemi/upub
fix: set published before converting to model
user may not have set it and we overwrite it anyway. id instead is necessary, so if it's not given we should return 500
This commit is contained in:
parent
83b545649f
commit
377ed9665d
1 changed files with 4 additions and 1 deletions
|
@ -288,7 +288,9 @@ impl apb::server::Outbox for Context {
|
|||
async fn update(&self, uid: String, activity: serde_json::Value) -> crate::Result<String> {
|
||||
let aid = self.aid(uuid::Uuid::new_v4().to_string());
|
||||
let object_node = activity.object().extract().ok_or_else(UpubError::bad_request)?;
|
||||
let mut object_model = model::object::Model::new(&object_node)?;
|
||||
let mut object_model = model::object::Model::new(
|
||||
&object_node.set_published(Some(chrono::Utc::now()))
|
||||
)?;
|
||||
|
||||
let old_object_model = model::object::Entity::find_by_id(&object_model.id)
|
||||
.one(self.db())
|
||||
|
@ -312,6 +314,7 @@ impl apb::server::Outbox for Context {
|
|||
object_model.to = old_object_model.to;
|
||||
object_model.bcc = old_object_model.bcc;
|
||||
object_model.cc = old_object_model.cc;
|
||||
object_model.published = old_object_model.published;
|
||||
|
||||
let addressed = activity.addressed();
|
||||
let activity_model = model::activity::Model::new(
|
||||
|
|
Loading…
Reference in a new issue