fix (backend-rs): use the exact same time for id and created_at

This commit is contained in:
naskya 2024-06-03 08:23:58 +09:00
parent 98d7eac51b
commit e87dae896b
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -1,6 +1,6 @@
use crate::database::db_conn;
use crate::model::entity::note_watching;
use crate::util::id::gen_id;
use crate::util::id::gen_id_at;
use sea_orm::{prelude::*, ActiveValue};
#[crate::export]
@ -10,9 +10,11 @@ pub async fn watch_note(
note_id: &str,
) -> Result<(), DbErr> {
if watcher_id != note_author_id {
let now = chrono::Utc::now();
note_watching::Entity::insert(note_watching::ActiveModel {
id: ActiveValue::set(gen_id()),
created_at: ActiveValue::set(chrono::Utc::now().into()),
id: ActiveValue::set(gen_id_at(now)),
created_at: ActiveValue::set(now.into()),
user_id: ActiveValue::Set(watcher_id.to_string()),
note_user_id: ActiveValue::Set(note_author_id.to_string()),
note_id: ActiveValue::Set(note_id.to_string()),