2023-08-28 23:02:43 -05:00
|
|
|
namespace dev
|
2023-06-15 07:10:20 -05:00
|
|
|
import std::str::StringBounds
|
|
|
|
|
|
|
|
settings {
|
|
|
|
indexed-all=false
|
|
|
|
allow-debugging=true
|
|
|
|
}
|
|
|
|
|
2023-06-23 22:16:35 -05:00
|
|
|
|
2023-08-28 23:02:43 -05:00
|
|
|
@affects=[struct protocol]
|
2023-06-23 22:16:35 -05:00
|
|
|
settings MailSettings {
|
2023-06-15 07:10:20 -05:00
|
|
|
indexed=true
|
|
|
|
}
|
|
|
|
|
2023-06-23 22:16:35 -05:00
|
|
|
|
2023-06-15 07:10:20 -05:00
|
|
|
@settings=MailSettings
|
|
|
|
struct Mail {
|
|
|
|
1# sender: str
|
|
|
|
2# recipient: str
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Article {
|
|
|
|
@validators=[StringBounds(min_chars=3 max_chars=32]
|
2023-08-28 23:02:43 -05:00
|
|
|
title: str
|
2023-06-15 07:10:20 -05:00
|
|
|
|
|
|
|
@validators=[StringBounds(min_chars=24 max_chars=412]
|
2023-08-28 23:02:43 -05:00
|
|
|
content: str
|
2023-06-15 07:10:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@hidden
|
|
|
|
@settings=MailSettings
|
|
|
|
protocol Mail {
|
2023-08-28 23:02:43 -05:00
|
|
|
async function send(mail: Mail)
|
2023-06-15 07:10:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Maximum amount of articles that a provider can send
|
|
|
|
const SENT_ARTICLES_MAX: u8 = 10
|
|
|
|
|
|
|
|
protocol Feed {
|
|
|
|
// Fetches new articles since last fetch
|
|
|
|
@flexible async stream
|
|
|
|
#timeout=1000ms per_send_timeout=10s cooldown=10s
|
2023-08-28 23:02:43 -05:00
|
|
|
function fetch_articles() -> Article[SENT_ARTICLES_MAX]
|
2023-06-15 07:10:20 -05:00
|
|
|
}
|