feat #14740: track uploads per backend server
Schema v4 adds calls.crm_base_url; existing uploads are tagged with the test backend. A call counts as uploaded (list/detail fields, the "Hochgeladen am" line, the upload-once guard) only if it was uploaded to this build's backend. Uploading to the other server replaces the single upload record; nothing is deleted. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,13 @@ pub struct CallListItem {
|
||||
}
|
||||
|
||||
impl CallListItem {
|
||||
pub fn of(call: &Call) -> Self {
|
||||
/// `backend_url` is this build's backend (`crate::backend::BACKEND_URL`
|
||||
/// in the app): an upload recorded for a different one is shown as not
|
||||
/// uploaded at all ([`uploaded_here`]) — e.g. a transcript sent to the
|
||||
/// test backend must not look done to a release build reading the same
|
||||
/// row. Nothing is deleted; the fields are just not shown as set.
|
||||
pub fn of(call: &Call, backend_url: &str) -> Self {
|
||||
let uploaded = uploaded_here(call, backend_url);
|
||||
Self {
|
||||
id: call.id,
|
||||
app: call.app.clone(),
|
||||
@@ -37,8 +43,12 @@ impl CallListItem {
|
||||
status: call.status,
|
||||
interrupted: call.interrupted,
|
||||
title: call.title.clone(),
|
||||
crm_transcript_id: call.crm_transcript_id.clone(),
|
||||
uploaded_at: call.uploaded_at,
|
||||
crm_transcript_id: if uploaded {
|
||||
call.crm_transcript_id.clone()
|
||||
} else {
|
||||
None
|
||||
},
|
||||
uploaded_at: if uploaded { call.uploaded_at } else { None },
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +60,16 @@ pub fn duration_secs(call: &Call) -> i64 {
|
||||
.map_or(0, |end| (end - call.started_at).num_seconds().max(0))
|
||||
}
|
||||
|
||||
/// Whether `call`'s upload belongs to `backend_url`: its
|
||||
/// `crm_transcript_id` is set *and* `crm_base_url` is exactly this
|
||||
/// backend. An upload recorded for a different one (e.g. the test backend,
|
||||
/// read by a release build) counts as not uploaded: the CRM this
|
||||
/// `backend_url` talks to has never seen the transcript, so the UI offers
|
||||
/// the normal upload control again instead of claiming it is done.
|
||||
pub fn uploaded_here(call: &Call, backend_url: &str) -> bool {
|
||||
call.crm_transcript_id.is_some() && call.crm_base_url.as_deref() == Some(backend_url)
|
||||
}
|
||||
|
||||
/// The selected call's header data: its list row plus the error of a
|
||||
/// failed run and when it was transcribed (only a transcribed call can be
|
||||
/// uploaded).
|
||||
@@ -104,12 +124,14 @@ pub struct CallDetail {
|
||||
|
||||
impl CallDetail {
|
||||
/// `segments` are the stored ones; `merges` the stored speaker merges
|
||||
/// (source key → target key).
|
||||
/// (source key → target key); `backend_url` is this build's backend
|
||||
/// (see [`CallListItem::of`]).
|
||||
pub fn of(
|
||||
call: &Call,
|
||||
segments: &[Segment],
|
||||
speaker_names: BTreeMap<String, String>,
|
||||
merges: &BTreeMap<String, String>,
|
||||
backend_url: &str,
|
||||
) -> Self {
|
||||
let segments = merge::apply_merges(segments, merges)
|
||||
.iter()
|
||||
@@ -123,7 +145,7 @@ impl CallDetail {
|
||||
.collect();
|
||||
Self {
|
||||
call: CallHeader {
|
||||
item: CallListItem::of(call),
|
||||
item: CallListItem::of(call, backend_url),
|
||||
error: call.error.clone(),
|
||||
transcribed_at: call.transcribed_at,
|
||||
},
|
||||
@@ -234,6 +256,11 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::model::Speaker;
|
||||
|
||||
/// This build's backend, for `CallListItem::of`/`CallDetail::of`.
|
||||
const BACKEND: &str = "https://backend.example";
|
||||
/// A different backend, for the "uploaded elsewhere" cases.
|
||||
const OTHER_BACKEND: &str = "https://other.example";
|
||||
|
||||
fn at(h: u32, m: u32, s: u32) -> DateTime<Local> {
|
||||
Local.with_ymd_and_hms(2026, 11, 5, h, m, s).unwrap()
|
||||
}
|
||||
@@ -253,6 +280,7 @@ mod tests {
|
||||
audio_deleted: false,
|
||||
title: None,
|
||||
crm_transcript_id: None,
|
||||
crm_base_url: None,
|
||||
uploaded_at: None,
|
||||
}
|
||||
}
|
||||
@@ -283,7 +311,7 @@ mod tests {
|
||||
c.status = CallStatus::AwaitingDecision;
|
||||
c.interrupted = true;
|
||||
assert_eq!(
|
||||
CallListItem::of(&c),
|
||||
CallListItem::of(&c, BACKEND),
|
||||
CallListItem {
|
||||
id: 7,
|
||||
app: "Microsoft Teams".into(),
|
||||
@@ -299,13 +327,51 @@ mod tests {
|
||||
|
||||
c.title = Some("Angebot Rioja".into());
|
||||
c.crm_transcript_id = Some("4711".into());
|
||||
c.crm_base_url = Some(BACKEND.into());
|
||||
c.uploaded_at = Some(at(11, 0, 0));
|
||||
let item = CallListItem::of(&c);
|
||||
let item = CallListItem::of(&c, BACKEND);
|
||||
assert_eq!(item.title.as_deref(), Some("Angebot Rioja"));
|
||||
assert_eq!(item.crm_transcript_id.as_deref(), Some("4711"));
|
||||
assert_eq!(item.uploaded_at, Some(at(11, 0, 0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uploaded_here_needs_a_transcript_id_and_a_matching_backend() {
|
||||
let mut c = call(Some(at(10, 15, 0)));
|
||||
assert!(!uploaded_here(&c, BACKEND), "never uploaded");
|
||||
|
||||
c.crm_transcript_id = Some("4711".into());
|
||||
c.crm_base_url = Some(OTHER_BACKEND.into());
|
||||
assert!(
|
||||
!uploaded_here(&c, BACKEND),
|
||||
"uploaded, but to a different backend"
|
||||
);
|
||||
|
||||
c.crm_base_url = Some(BACKEND.into());
|
||||
assert!(uploaded_here(&c, BACKEND));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_upload_to_another_backend_is_hidden_from_the_list_item() {
|
||||
// Uploaded to OTHER_BACKEND; this build's backend is BACKEND: the
|
||||
// row still has crm_transcript_id/uploaded_at, but the view must
|
||||
// not show them, so the UI offers the normal upload control again.
|
||||
let mut c = call(Some(at(10, 15, 0)));
|
||||
c.crm_transcript_id = Some("4711".into());
|
||||
c.crm_base_url = Some(OTHER_BACKEND.into());
|
||||
c.uploaded_at = Some(at(11, 0, 0));
|
||||
|
||||
let item = CallListItem::of(&c, BACKEND);
|
||||
assert_eq!(item.crm_transcript_id, None);
|
||||
assert_eq!(item.uploaded_at, None);
|
||||
|
||||
// The same row, read by a build whose backend actually matches:
|
||||
// shown normally.
|
||||
let item = CallListItem::of(&c, OTHER_BACKEND);
|
||||
assert_eq!(item.crm_transcript_id.as_deref(), Some("4711"));
|
||||
assert_eq!(item.uploaded_at, Some(at(11, 0, 0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detail_labels_segments_with_renames_and_defaults() {
|
||||
let segments = [
|
||||
@@ -322,6 +388,7 @@ mod tests {
|
||||
&segments,
|
||||
names.clone(),
|
||||
&BTreeMap::new(),
|
||||
BACKEND,
|
||||
);
|
||||
|
||||
let lines: Vec<_> = detail
|
||||
@@ -366,7 +433,13 @@ mod tests {
|
||||
("remote:10", "remote:4"),
|
||||
]);
|
||||
|
||||
let detail = CallDetail::of(&call(Some(at(10, 15, 0))), &segments, names, &merges);
|
||||
let detail = CallDetail::of(
|
||||
&call(Some(at(10, 15, 0))),
|
||||
&segments,
|
||||
names,
|
||||
&merges,
|
||||
BACKEND,
|
||||
);
|
||||
|
||||
let lines: Vec<_> = detail
|
||||
.segments
|
||||
@@ -418,7 +491,8 @@ mod tests {
|
||||
let merges = keys(&[("remote:2", "remote:1")]);
|
||||
|
||||
let value =
|
||||
serde_json::to_value(CallDetail::of(&c, &[], BTreeMap::new(), &merges)).unwrap();
|
||||
serde_json::to_value(CallDetail::of(&c, &[], BTreeMap::new(), &merges, BACKEND))
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
value,
|
||||
@@ -450,7 +524,13 @@ mod tests {
|
||||
}
|
||||
|
||||
fn detail_with(c: &Call, segments: &[Segment], names: &[(&str, &str)]) -> CallDetail {
|
||||
CallDetail::of(c, segments, keys(names), &keys(&[("remote:2", "remote:1")]))
|
||||
CallDetail::of(
|
||||
c,
|
||||
segments,
|
||||
keys(names),
|
||||
&keys(&[("remote:2", "remote:1")]),
|
||||
BACKEND,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -41,6 +41,11 @@ pub struct Call {
|
||||
pub title: Option<String>,
|
||||
/// The id the CRM gave the transcript at its last upload.
|
||||
pub crm_transcript_id: Option<String>,
|
||||
/// The backend ([`crate::backend`]'s base URL) `crm_transcript_id` was
|
||||
/// uploaded to; `None` if never uploaded. A build whose own backend
|
||||
/// differs (e.g. release reading a row a test build uploaded) does not
|
||||
/// count this as uploaded — see `call_view::uploaded_here`.
|
||||
pub crm_base_url: Option<String>,
|
||||
/// When the transcript was last uploaded.
|
||||
pub uploaded_at: Option<DateTime<Local>>,
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ mod tests {
|
||||
audio_deleted: false,
|
||||
title: None,
|
||||
crm_transcript_id: None,
|
||||
crm_base_url: None,
|
||||
uploaded_at: None,
|
||||
}
|
||||
}
|
||||
|
||||
+121
-22
@@ -120,9 +120,19 @@ ALTER TABLE calls ADD COLUMN crm_transcript_id TEXT;
|
||||
ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
";
|
||||
|
||||
/// Version 4: which backend an upload belongs to, so a build whose own
|
||||
/// backend differs (see `crate::backend`) does not show someone else's
|
||||
/// upload as done (`call_view::uploaded_here`). Every upload before this
|
||||
/// version only ever went to the test backend (production never had the
|
||||
/// API yet): backfilled here, so existing rows keep meaning what they did.
|
||||
const SCHEMA_V4_SQL: &str = "
|
||||
ALTER TABLE calls ADD COLUMN crm_base_url TEXT;
|
||||
UPDATE calls SET crm_base_url = 'https://test.euvinopro.eu' WHERE crm_transcript_id IS NOT NULL;
|
||||
";
|
||||
|
||||
/// Schema steps by `PRAGMA user_version`: entry `i` takes a database from
|
||||
/// version `i` to `i + 1`. A new database runs all of them.
|
||||
const MIGRATIONS: &[&str] = &[SCHEMA_V1_SQL, SCHEMA_V2_SQL, SCHEMA_V3_SQL];
|
||||
const MIGRATIONS: &[&str] = &[SCHEMA_V1_SQL, SCHEMA_V2_SQL, SCHEMA_V3_SQL, SCHEMA_V4_SQL];
|
||||
|
||||
/// SQLite-backed store for calls and everything derived from them.
|
||||
pub struct Store {
|
||||
@@ -361,18 +371,21 @@ impl Store {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Records that the transcript was uploaded to the CRM at `at`, which
|
||||
/// gave it `crm_transcript_id`; replaces an earlier upload's record.
|
||||
/// Records that the transcript was uploaded to `crm_base_url` at `at`,
|
||||
/// which gave it `crm_transcript_id`; replaces an earlier upload's
|
||||
/// record (even one of another backend — one upload slot per call, see
|
||||
/// `call_view::uploaded_here`).
|
||||
pub fn set_uploaded(
|
||||
&self,
|
||||
id: CallId,
|
||||
crm_transcript_id: &str,
|
||||
crm_base_url: &str,
|
||||
at: DateTime<Local>,
|
||||
) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
"UPDATE calls SET crm_transcript_id = ?1, uploaded_at = ?2 WHERE id = ?3",
|
||||
params![crm_transcript_id, dt_to_str(at), id],
|
||||
"UPDATE calls SET crm_transcript_id = ?1, crm_base_url = ?2, uploaded_at = ?3 WHERE id = ?4",
|
||||
params![crm_transcript_id, crm_base_url, dt_to_str(at), id],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -536,9 +549,9 @@ fn ids_with_status(conn: &rusqlite::Connection, status: CallStatus) -> Result<Ve
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
const SELECT_ALL_CALLS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at FROM calls";
|
||||
const SELECT_ALL_CALLS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at, crm_base_url FROM calls";
|
||||
|
||||
const SELECT_CALL_COLUMNS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at FROM calls WHERE id = ?1";
|
||||
const SELECT_CALL_COLUMNS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at, crm_base_url FROM calls WHERE id = ?1";
|
||||
|
||||
fn row_to_call(row: &Row) -> Result<Call> {
|
||||
let id: CallId = row.get(0)?;
|
||||
@@ -555,6 +568,7 @@ fn row_to_call(row: &Row) -> Result<Call> {
|
||||
let title: Option<String> = row.get(11)?;
|
||||
let crm_transcript_id: Option<String> = row.get(12)?;
|
||||
let uploaded_at: Option<String> = row.get(13)?;
|
||||
let crm_base_url: Option<String> = row.get(14)?;
|
||||
|
||||
Ok(Call {
|
||||
id,
|
||||
@@ -570,6 +584,7 @@ fn row_to_call(row: &Row) -> Result<Call> {
|
||||
audio_deleted,
|
||||
title,
|
||||
crm_transcript_id,
|
||||
crm_base_url,
|
||||
uploaded_at: opt_dt_from_str(uploaded_at)?,
|
||||
})
|
||||
}
|
||||
@@ -692,6 +707,14 @@ CREATE TABLE speaker_merges (
|
||||
into_key TEXT NOT NULL,
|
||||
PRIMARY KEY (call_id, from_key)
|
||||
);
|
||||
";
|
||||
|
||||
/// The schema of user_version 3, exactly as release 0.2.0 created it
|
||||
/// (copied from `SCHEMA_V3_SQL` at `HEAD`): version 2 plus these
|
||||
/// statements.
|
||||
const RELEASED_V3_STEP_SQL: &str = "
|
||||
ALTER TABLE calls ADD COLUMN crm_transcript_id TEXT;
|
||||
ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
";
|
||||
|
||||
fn user_version(path: &Path) -> i64 {
|
||||
@@ -715,17 +738,19 @@ CREATE TABLE speaker_merges (
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_new_database_starts_at_version_3() {
|
||||
fn a_new_database_starts_at_version_4() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("calls.sqlite");
|
||||
let store = Store::open(&path).unwrap();
|
||||
let id = new_call(&store);
|
||||
store.set_title(id, Some("Angebot")).unwrap();
|
||||
store.set_speaker_merge(id, "remote:2", "remote:1").unwrap();
|
||||
store.set_uploaded(id, "4711", Local::now()).unwrap();
|
||||
store
|
||||
.set_uploaded(id, "4711", "https://backend.example", Local::now())
|
||||
.unwrap();
|
||||
drop(store);
|
||||
|
||||
assert_eq!(user_version(&path), 3);
|
||||
assert_eq!(user_version(&path), 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -782,7 +807,7 @@ CREATE TABLE speaker_merges (
|
||||
store.set_title(1, Some("Lieferung März")).unwrap();
|
||||
store.set_speaker_merge(1, "remote:2", "remote:1").unwrap();
|
||||
drop(store);
|
||||
assert_eq!(user_version(&path), 3);
|
||||
assert_eq!(user_version(&path), 4);
|
||||
let store = Store::open(&path).unwrap();
|
||||
let call = store.get_call(1).unwrap().unwrap();
|
||||
assert_eq!(call.title.as_deref(), Some("Lieferung März"));
|
||||
@@ -832,41 +857,115 @@ CREATE TABLE speaker_merges (
|
||||
|
||||
// The new columns work, and opening again changes nothing.
|
||||
let uploaded = Local::now();
|
||||
store.set_uploaded(1, "crm-1", uploaded).unwrap();
|
||||
store
|
||||
.set_uploaded(1, "crm-1", "https://backend.example", uploaded)
|
||||
.unwrap();
|
||||
drop(store);
|
||||
assert_eq!(user_version(&path), 3);
|
||||
assert_eq!(user_version(&path), 4);
|
||||
let store = Store::open(&path).unwrap();
|
||||
let call = store.get_call(1).unwrap().unwrap();
|
||||
assert_eq!(call.crm_transcript_id.as_deref(), Some("crm-1"));
|
||||
assert_eq!(
|
||||
call.crm_base_url.as_deref(),
|
||||
Some("https://backend.example")
|
||||
);
|
||||
assert_eq!(call.uploaded_at, Some(uploaded));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_upload_is_recorded_and_replaced_by_the_next() {
|
||||
fn a_version_3_database_is_upgraded_backfilling_the_test_backend_for_uploads() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("calls.sqlite");
|
||||
let started = "2026-11-05T10:14:00+01:00";
|
||||
{
|
||||
let conn = rusqlite::Connection::open(&path).unwrap();
|
||||
conn.execute_batch(RELEASED_V1_SCHEMA_SQL).unwrap();
|
||||
conn.execute_batch(RELEASED_V2_STEP_SQL).unwrap();
|
||||
conn.execute_batch(RELEASED_V3_STEP_SQL).unwrap();
|
||||
conn.execute_batch("PRAGMA user_version = 3;").unwrap();
|
||||
// An already-uploaded call (every pre-v4 upload went to the
|
||||
// test backend; production never had the API).
|
||||
conn.execute(
|
||||
"INSERT INTO calls \
|
||||
(app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, account_id, title, crm_transcript_id, uploaded_at) \
|
||||
VALUES ('Microsoft Teams', ?1, ?1, 'done', 0, NULL, '/rec/1-mic.wav', '/rec/1-out.wav', ?1, 0, NULL, NULL, 'crm-1', ?1)",
|
||||
rusqlite::params![started],
|
||||
)
|
||||
.unwrap();
|
||||
// A call that was never uploaded.
|
||||
conn.execute(
|
||||
"INSERT INTO calls \
|
||||
(app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, account_id, title, crm_transcript_id, uploaded_at) \
|
||||
VALUES ('MicroSIP', ?1, NULL, 'awaiting_decision', 0, NULL, '/rec/2-mic.wav', '/rec/2-out.wav', NULL, 0, NULL, NULL, NULL, NULL)",
|
||||
rusqlite::params![started],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let store = Store::open(&path).unwrap();
|
||||
|
||||
let uploaded = store.get_call(1).unwrap().expect("call kept");
|
||||
assert_eq!(uploaded.crm_transcript_id.as_deref(), Some("crm-1"));
|
||||
assert_eq!(
|
||||
uploaded.crm_base_url.as_deref(),
|
||||
Some("https://test.euvinopro.eu")
|
||||
);
|
||||
|
||||
let not_uploaded = store.get_call(2).unwrap().expect("call kept");
|
||||
assert_eq!(not_uploaded.crm_transcript_id, None);
|
||||
assert_eq!(not_uploaded.crm_base_url, None);
|
||||
|
||||
assert_eq!(user_version(&path), 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_upload_is_recorded_and_replaced_by_the_next_even_for_another_backend() {
|
||||
let store = Store::open_in_memory().unwrap();
|
||||
let id = new_call(&store);
|
||||
let other = new_call(&store);
|
||||
let first = Local::now();
|
||||
let second = first + chrono::Duration::minutes(5);
|
||||
|
||||
store.set_uploaded(id, "4711", first).unwrap();
|
||||
store
|
||||
.set_uploaded(id, "4711", "https://test.euvinopro.eu", first)
|
||||
.unwrap();
|
||||
let call = store.get_call(id).unwrap().unwrap();
|
||||
assert_eq!(
|
||||
(call.crm_transcript_id.as_deref(), call.uploaded_at),
|
||||
(Some("4711"), Some(first))
|
||||
(
|
||||
call.crm_transcript_id.as_deref(),
|
||||
call.crm_base_url.as_deref(),
|
||||
call.uploaded_at
|
||||
),
|
||||
(Some("4711"), Some("https://test.euvinopro.eu"), Some(first))
|
||||
);
|
||||
|
||||
store.set_uploaded(id, "4712", second).unwrap();
|
||||
// One upload slot per call: a later upload, even to a different
|
||||
// backend, replaces it rather than keeping both.
|
||||
store
|
||||
.set_uploaded(id, "4712", "https://backend.euvinopro.eu", second)
|
||||
.unwrap();
|
||||
let listed = store.list_calls().unwrap();
|
||||
let call = listed.iter().find(|c| c.id == id).unwrap();
|
||||
assert_eq!(
|
||||
(call.crm_transcript_id.as_deref(), call.uploaded_at),
|
||||
(Some("4712"), Some(second))
|
||||
(
|
||||
call.crm_transcript_id.as_deref(),
|
||||
call.crm_base_url.as_deref(),
|
||||
call.uploaded_at
|
||||
),
|
||||
(
|
||||
Some("4712"),
|
||||
Some("https://backend.euvinopro.eu"),
|
||||
Some(second)
|
||||
)
|
||||
);
|
||||
let untouched = store.get_call(other).unwrap().unwrap();
|
||||
assert_eq!(
|
||||
(untouched.crm_transcript_id, untouched.uploaded_at),
|
||||
(None, None)
|
||||
(
|
||||
untouched.crm_transcript_id,
|
||||
untouched.crm_base_url,
|
||||
untouched.uploaded_at
|
||||
),
|
||||
(None, None, None)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user