Commit 69627b1d authored by Stephane Glondu's avatar Stephane Glondu

Introduce a limit on the number of mails sent at once

parent 8fb41608
......@@ -37,6 +37,7 @@
<static dir="_SRCDIR_/_build/src/static" />
</site>
<eliom module="_build/src/web/server.cma">
<maxmailsatonce value="1000"/>
<auth name="demo"><dummy/></auth>
<auth name="local"><password db="demo/password_db.csv"/></auth>
<!-- <auth name="google"><oidc server="https://accounts.google.com" client_id="client-id" client_secret="client-secret"/></auth> -->
......
......@@ -48,6 +48,8 @@ let () =
Lwt_main.run (open_security_log file)
| Element ("source", ["file", file], []) ->
source_file := Some file
| Element ("maxmailsatonce", ["value", limit], []) ->
Web_site.maxmailsatonce := int_of_string limit
| Element ("spool", ["dir", dir], []) ->
spool_dir := Some dir
| Element ("rewrite-prefix", ["src", src; "dst", dst], []) ->
......
......@@ -30,6 +30,7 @@ open Web_common
open Web_services
let source_file = ref "belenios.tar.gz"
let maxmailsatonce = ref 1000
let ( / ) = Filename.concat
......@@ -483,6 +484,9 @@ let generate_password langs title url id =
return (salt, hashed)
let handle_password se uuid ~force voters =
if List.length voters > !maxmailsatonce then
Lwt.fail (Failure (Printf.sprintf "Cannot send passwords, there are too many voters (max is %d)" !maxmailsatonce))
else
let title = se.se_questions.t_name in
let url = Eliom_uri.make_string_uri ~absolute:true ~service:election_home
(uuid, ()) |> rewrite_prefix
......@@ -780,6 +784,9 @@ let () =
Any.register
~service:election_setup_credentials_server
(handle_setup (fun se () _ uuid ->
if List.length se.se_voters > !maxmailsatonce then
Lwt.fail (Failure (Printf.sprintf "Cannot send credentials, there are too many voters (max is %d)" !maxmailsatonce))
else
if se.se_public_creds_received then forbidden () else
let () = se.se_metadata <- {se.se_metadata with
e_cred_authority = Some "server"
......
......@@ -20,3 +20,4 @@
(**************************************************************************)
val source_file : string ref
val maxmailsatonce : int ref
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment