Compare commits
No commits in common. "52a89428f3295d35db7bfddc3d7dd28d93e36159" and "629e13710d513c094df0aa1891636cb50e0dc39f" have entirely different histories.
52a89428f3
...
629e13710d
@ -7,7 +7,7 @@ user_id: "@mybebot:example.com"
|
||||
# Password for Matrix user.
|
||||
password: "secret-matrix-account-password"
|
||||
# All Gitlab-specific settings are under here.
|
||||
gitlab_webhook:
|
||||
gitlab:
|
||||
# Optional prefix to serve the webhook path under (default is empty string).
|
||||
url_prefix: "/bebot"
|
||||
# Default Matrix room to publish Gitlab events to.
|
||||
@ -58,28 +58,3 @@ gitlab_webhook:
|
||||
"gitlab.example.com/myuser/some-other-less-cool-app":
|
||||
token: "kljaslkdjaklsdjalksd"
|
||||
# This repo uses the default events and room.
|
||||
# The mail_archive configuration section allows you to set up bebot to publish
|
||||
# messages based on RSS feeds from mail-archive.com.
|
||||
mail_archive:
|
||||
# List of rooms that will be published to by default, unless overridden by
|
||||
# a per-list config.
|
||||
default_rooms:
|
||||
- "#some-room:example.com"
|
||||
- "#some-other-room:example.com"
|
||||
# How often bebot will fetch the RSS feed to check for updates, in seconds.
|
||||
update_interval: 60
|
||||
# A directory where bebot can store state, such as the data of the last
|
||||
# entry in the RSS feed it has seen.
|
||||
state_dir: "/var/lib/bebot/mail-archive-state"
|
||||
# A list of mailing lists.
|
||||
lists:
|
||||
# This is the list name as is displayed in mail-archive.com URLS.
|
||||
- name: "my-list@example.com"
|
||||
# Disable publishing a matrix message for replies sent to the list
|
||||
# (default true). This isn't perfect, and can only guess if a message
|
||||
# is a reply based on the subject line.
|
||||
publish_on_replies: false
|
||||
# An optional list of rooms to publish to. If not specified, the
|
||||
# default_rooms setting above will be used.
|
||||
rooms:
|
||||
- "#yet-some-other-room:example.com"
|
||||
|
@ -65,8 +65,6 @@ pub struct GitlabWebhookConfig {
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct MailListConfig {
|
||||
pub name: String,
|
||||
#[serde(default = "default_true")]
|
||||
pub publish_on_replies: bool,
|
||||
#[serde(default)]
|
||||
pub rooms: Vec<OwnedRoomOrAliasId>,
|
||||
}
|
||||
@ -91,10 +89,6 @@ pub struct Config {
|
||||
pub mail_archive: Option<MailArchiveConfig>,
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn load_blocking(path: &String) -> anyhow::Result<Config> {
|
||||
let f = File::open(path)?;
|
||||
let r = BufReader::new(f);
|
||||
|
@ -41,7 +41,10 @@ pub fn build_gitlab_messages(event: &GitlabEvent) -> Vec<String> {
|
||||
format!(
|
||||
"\\[{}\\] {}*{}* {}",
|
||||
project.path_with_namespace,
|
||||
refname.as_ref().map(|rn| format!("`{}` ", rn)).unwrap_or_default(),
|
||||
refname
|
||||
.as_ref()
|
||||
.map(|rn| format!("`{}` ", rn))
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
event.user(),
|
||||
title,
|
||||
)
|
||||
|
@ -105,7 +105,6 @@ async fn handle_list(
|
||||
http_client: &reqwest::Client,
|
||||
url: &String,
|
||||
matrix_client: &Client,
|
||||
publish_on_replies: bool,
|
||||
room_ids: &[OwnedRoomOrAliasId],
|
||||
) -> anyhow::Result<()> {
|
||||
let list_state = load_list_state(state_file).await?;
|
||||
@ -162,15 +161,11 @@ async fn handle_list(
|
||||
|
||||
for room in rooms {
|
||||
for item in &items {
|
||||
if publish_on_replies || !item.title.starts_with("Re: ") {
|
||||
let msg = RoomMessageEventContent::text_markdown(format!(
|
||||
"\\[{}\\] [{}]({})",
|
||||
list.name, item.title, item.link
|
||||
));
|
||||
room.send(msg, None)
|
||||
.await
|
||||
.with_context(|| format!("Failed to send message to room '{}'", room.room_id()))?;
|
||||
}
|
||||
let msg =
|
||||
RoomMessageEventContent::text_markdown(format!("\\[{}\\] [{}]({})", list.name, item.title, item.link));
|
||||
room.send(msg, None)
|
||||
.await
|
||||
.with_context(|| format!("Failed to send message to room '{}'", room.room_id()))?;
|
||||
save_list_state(
|
||||
ListState {
|
||||
last_pub_date: item.pub_date.value,
|
||||
@ -212,16 +207,8 @@ pub fn start_polling(config: MailArchiveConfig, matrix_client: Client) -> anyhow
|
||||
tokio::spawn(async move {
|
||||
if !room_ids.is_empty() {
|
||||
loop {
|
||||
if let Err(err) = handle_list(
|
||||
&list,
|
||||
&state_file,
|
||||
&http_client,
|
||||
&url,
|
||||
&matrix_client,
|
||||
list.publish_on_replies,
|
||||
&room_ids,
|
||||
)
|
||||
.await
|
||||
if let Err(err) =
|
||||
handle_list(&list, &state_file, &http_client, &url, &matrix_client, &room_ids).await
|
||||
{
|
||||
warn!("{:#}", err);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user