fix timestamp format for AT Protocol compatibility
Use ISO 8601 with milliseconds and Z suffix instead of rfc3339 with nanoseconds and +00:00 offset. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -326,6 +326,11 @@ fn new_id() -> String {
|
||||
Uuid::new_v4().to_string().replace('-', "")[..13].to_string()
|
||||
}
|
||||
|
||||
/// ISO 8601 format compatible with AT Protocol: "2026-03-22T07:21:00.448Z"
|
||||
fn now_iso() -> String {
|
||||
Utc::now().format("%Y-%m-%dT%H:%M:%S%.3fZ").to_string()
|
||||
}
|
||||
|
||||
// --- DB ---
|
||||
|
||||
fn init_db(conn: &Connection) {
|
||||
@@ -395,7 +400,7 @@ fn init_db(conn: &Connection) {
|
||||
fn ensure_account(conn: &Connection, did: &str) {
|
||||
conn.execute(
|
||||
"INSERT OR IGNORE INTO accounts (did, handle, created_at) VALUES (?1, ?2, ?3)",
|
||||
rusqlite::params![did, did, Utc::now().to_rfc3339()],
|
||||
rusqlite::params![did, did, now_iso()],
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
@@ -432,7 +437,7 @@ fn get_or_create_convo(conn: &Connection, members: &[String]) -> ConvoView {
|
||||
// Create new convo
|
||||
let id = new_id();
|
||||
let rev = new_rev();
|
||||
let now = Utc::now().to_rfc3339();
|
||||
let now = now_iso();
|
||||
|
||||
conn.execute(
|
||||
"INSERT INTO convos (id, rev, created_at, updated_at) VALUES (?1, ?2, ?3, ?4)",
|
||||
@@ -459,7 +464,7 @@ fn get_or_create_convo(conn: &Connection, members: &[String]) -> ConvoView {
|
||||
}
|
||||
|
||||
fn add_log(conn: &Connection, convo_id: &str, rev: &str, log_type: &str, data: serde_json::Value) {
|
||||
let now = Utc::now().to_rfc3339();
|
||||
let now = now_iso();
|
||||
conn.execute(
|
||||
"INSERT INTO logs (convo_id, rev, log_type, data, created_at) VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
rusqlite::params![convo_id, rev, log_type, data.to_string(), now],
|
||||
@@ -583,7 +588,7 @@ fn build_message_json(row: &rusqlite::Row) -> rusqlite::Result<serde_json::Value
|
||||
fn insert_message(conn: &Connection, convo_id: &str, did: &str, msg: &MessageInput) -> (String, String, String) {
|
||||
let msg_id = new_id();
|
||||
let rev = new_rev();
|
||||
let now = Utc::now().to_rfc3339();
|
||||
let now = now_iso();
|
||||
let facets_str = msg.facets.as_ref().map(|v| v.to_string());
|
||||
let embed_str = msg.embed.as_ref().map(|v| v.to_string());
|
||||
|
||||
@@ -966,7 +971,7 @@ async fn delete_message_for_self(
|
||||
let did = require_auth(&headers)?;
|
||||
let db = state.db.lock().unwrap();
|
||||
let rev = new_rev();
|
||||
let now = Utc::now().to_rfc3339();
|
||||
let now = now_iso();
|
||||
|
||||
db.execute(
|
||||
"UPDATE messages SET deleted = 1, rev = ?1 WHERE id = ?2 AND convo_id = ?3",
|
||||
@@ -1020,7 +1025,7 @@ async fn add_reaction(
|
||||
) -> Result<Json<serde_json::Value>, (StatusCode, Json<ErrorResp>)> {
|
||||
let did = require_auth(&headers)?;
|
||||
let db = state.db.lock().unwrap();
|
||||
let now = Utc::now().to_rfc3339();
|
||||
let now = now_iso();
|
||||
let rev = new_rev();
|
||||
|
||||
db.execute(
|
||||
|
||||
Reference in New Issue
Block a user