Use simpler routes for Dovecot

master
kaiyou 6 years ago
parent 82140baa69
commit d8365bfbcf

@ -93,7 +93,7 @@ def postfix_transport(email):
return flask.abort(404) return flask.abort(404)
@internal.route("/dovecot/auth/passdb/<user_email>") @internal.route("/dovecot/passdb/<user_email>")
def dovecot_passdb_dict(user_email): def dovecot_passdb_dict(user_email):
user = models.User.query.get(user_email) or flask.abort(403) user = models.User.query.get(user_email) or flask.abort(403)
return flask.jsonify({ return flask.jsonify({
@ -101,7 +101,7 @@ def dovecot_passdb_dict(user_email):
}) })
@internal.route("/dovecot/auth/userdb/<user_email>") @internal.route("/dovecot/userdb/<user_email>")
def dovecot_userdb_dict(user_email): def dovecot_userdb_dict(user_email):
user = models.User.query.get(user_email) or flask.abort(403) user = models.User.query.get(user_email) or flask.abort(403)
return flask.jsonify({ return flask.jsonify({
@ -109,10 +109,11 @@ def dovecot_userdb_dict(user_email):
}) })
@internal.route("/dovecot/quota/quota/<ns>/<user_email>", methods=["POST"]) @internal.route("/dovecot/quota/<ns>/<user_email>", methods=["POST"])
def dovecot_quota(ns, user_email): def dovecot_quota(ns, user_email):
user = models.User.query.get(user_email) or flask.abort(403) user = models.User.query.get(user_email) or flask.abort(403)
if ns == "storage": if ns == "storage":
user.quota_bytes_used = flask.request.get_json() user.quota_bytes_used = flask.request.get_json()
db.session.commit() db.session.commit()
return flask.jsonify(None) return flask.jsonify(None)

@ -12,9 +12,9 @@ from podop import run_server
def start_podop(): def start_podop():
os.setuid(8) os.setuid(8)
run_server(40, "dovecot", "/tmp/podop.socket", [ run_server(40, "dovecot", "/tmp/podop.socket", [
("quota", "url", "http://admin/internal/dovecot/quota/§"), ("quota", "url", "http://admin/internal/dovecot/§"),
("auth", "url", "http://admin/internal/dovecot/auth/§"), ("auth", "url", "http://admin/internal/dovecot/§"),
("sieve", "url", "http://admin/internal/dovecot/sieve/§"), ("sieve", "url", "http://admin/internal/dovecot/§"),
]) ])
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ)) convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))

Loading…
Cancel
Save