Diff
Logged in as anonymous

Differences From Artifact [9d854f6a4d]:

To Artifact [e0c853214b]:


1
2
3
4
5
6
7
8
9
10




11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
19
20









-
+
+
+
+







use anyhow::Result;
use async_std::task;
use samotop::{
	mail::{
		Builder,
		DebugService,
		MailDir,
		Name
	},
	smtp::Prudence,
	smtp::{
		SmtpParser,
		Prudence,
	},
};
use telegram_bot::{
	Api,
	ParseMode,
	SendMessage,
	UserId,
};
222
223
224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
239
240


241
242
243
244








245
246
225
226
227
228
229
230
231



232
233
234
235
236
237
238
239
240
241
242
243




244
245
246
247
248
249
250
251
252
253







-
-
-
+









+
+
-
-
-
-
+
+
+
+
+
+
+
+


		.add_source(config::File::with_name("smtp2tg.toml"))
		.build().unwrap();

	let core = TelegramTransport::new(&settings);
	let maildir: PathBuf = settings.get_string("maildir").unwrap().into();
	let listen_on = settings.get_string("listen_on").unwrap();
	let sink = Builder + Name::new("smtp2tg") + DebugService +
		samotop::smtp::Esmtp.with(samotop::smtp::SmtpParser) + my_prudence() +
		//TelegramTransport::new(&settings);
		MailDir::new(maildir.clone()).unwrap();
		my_prudence() + MailDir::new(maildir.clone()).unwrap();

	task::spawn(async move {
		loop {
			relay_mails(&maildir, &core).unwrap();
			task::sleep(Duration::from_secs(5)).await;
		}
	});

	match listen_on.as_str() {
		"socket" => {
			let sink = sink + samotop::smtp::Lmtp.with(SmtpParser);
		"socket" => samotop::server::UnixServer::on("./smtp2tg.sock")
			.serve(sink.build()).await.unwrap(),
		_ => samotop::server::TcpServer::on(listen_on)
			.serve(sink.build()).await.unwrap(),
			samotop::server::UnixServer::on("./smtp2tg.sock")
				.serve(sink.build()).await.unwrap();
		},
		_ => {
			let sink = sink + samotop::smtp::Esmtp.with(SmtpParser);
			samotop::server::TcpServer::on(listen_on)
				.serve(sink.build()).await.unwrap();
		},
	};
}