1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use axum::extract::FromRef;
use faker_rand::lorem::Paragraphs;
use crate::{
clock::RequestedAt,
conversation::Conversation,
login::Login,
message::{self, Body, Message, app::Messages},
};
pub async fn send<App>(
app: &App,
conversation: &Conversation,
sender: &Login,
sent_at: &RequestedAt,
) -> Message
where
Messages: FromRef<App>,
{
let body = propose();
Messages::from_ref(app)
.send(&conversation.id, sender, sent_at, &body)
.await
.expect("should succeed if the conversation exists")
}
pub fn propose() -> Body {
rand::random::<Paragraphs>().to_string().into()
}
pub fn fictitious() -> message::Id {
message::Id::generate()
}
|