mirror of
https://github.com/Mailu/Mailu.git
synced 2024-12-12 10:45:38 +02:00
Implement some basic views for podop
This commit is contained in:
parent
39cd0d5034
commit
7143fb8c47
@ -52,6 +52,18 @@ def basic_authentication():
|
||||
return response
|
||||
|
||||
|
||||
@internal.route("/postfix/domain/<domain_name>")
|
||||
def postfix_mailbox_domain(domain_name):
|
||||
domain = models.Domain.query.get(domain_name) or flask.abort(404)
|
||||
return flask.jsonify(domain.name)
|
||||
|
||||
|
||||
@internal.route("/postfix/mailbox/<email>")
|
||||
def postfix_mailbox_map(email):
|
||||
user = models.User.query.get(email) or flask.abort(404)
|
||||
return flask.jsonify(user.email)
|
||||
|
||||
|
||||
@internal.route("/postfix/alias/<alias>")
|
||||
def postfix_alias_map(alias):
|
||||
localpart, domain = alias.split('@', 1) if '@' in alias else (None, alias)
|
||||
@ -60,35 +72,25 @@ def postfix_alias_map(alias):
|
||||
domain = alternative.domain_name
|
||||
email = '{}@{}'.format(localpart, domain)
|
||||
if localpart is None:
|
||||
return domain
|
||||
return flask.jsonify(domain)
|
||||
else:
|
||||
alias_obj = models.Alias.resolve(localpart, domain)
|
||||
if alias_obj:
|
||||
return alias_obj.destination
|
||||
return flask.jsonify(alias_obj.destination)
|
||||
user_obj = models.User.query.get(email)
|
||||
if user_obj:
|
||||
return user_obj.destination
|
||||
flask.abort(404)
|
||||
return flask.jsonify(user_obj.destination)
|
||||
return flask.abort(404)
|
||||
|
||||
|
||||
@internal.route("/postfix/alias/domain/<domain>")
|
||||
def postfix_alias_domain(domain):
|
||||
pass
|
||||
@internal.route("/postfix/spoofed/<email>")
|
||||
def postfix_spoofed(email):
|
||||
return flask.abort(404)
|
||||
|
||||
|
||||
@internal.route("/postfix/alias/map/<alias>")
|
||||
def postfix_alias_map(alias):
|
||||
pass
|
||||
|
||||
|
||||
@internal.route("/postfix/mailbox/domain/<domain>")
|
||||
def postfix_mailbox_domain(domain):
|
||||
pass
|
||||
|
||||
|
||||
@internal.route("/postfix/mailbox/map/<mailbox>")
|
||||
def postfix_mailbox_map(domain):
|
||||
pass
|
||||
@internal.route("/postfix/transport/<email>")
|
||||
def postfix_transport(email):
|
||||
return flask.abort(404)
|
||||
|
||||
|
||||
@internal.route("/dovecot/auth/passdb/<user_email>")
|
||||
|
@ -268,7 +268,7 @@ class User(Base, Email):
|
||||
|
||||
@property
|
||||
def destination(self):
|
||||
if self.foward_enabled:
|
||||
if self.forward_enabled:
|
||||
result = self.self.forward_destination
|
||||
if self.forward_keep:
|
||||
result += ',' + self.email
|
||||
@ -339,13 +339,13 @@ class Alias(Base, Email):
|
||||
@classmethod
|
||||
def resolve(cls, localpart, domain_name):
|
||||
return cls.query.filter(
|
||||
sqlalchemy._and(cls.domain_name == domain_name,
|
||||
sqlalchemy._or(
|
||||
sqlalchemy.and_(cls.domain_name == domain_name,
|
||||
sqlalchemy.or_(
|
||||
cls.localpart == localpart,
|
||||
cls.wildcard.like(localpart)
|
||||
)
|
||||
)
|
||||
)
|
||||
).first()
|
||||
|
||||
|
||||
class Token(Base):
|
||||
|
@ -15,7 +15,7 @@ def start_podop():
|
||||
run_server(40, "postfix", "/tmp/podop.socket", [
|
||||
("transport", "url", "http://admin/internal/postfix/transport/§"),
|
||||
("alias", "url", "http://admin/internal/postfix/alias/§"),
|
||||
("domains", "url", "http://admin/internal/postfix/domains/§"),
|
||||
("domain", "url", "http://admin/internal/postfix/domain/§"),
|
||||
("mailbox", "url", "http://admin/internal/postfix/mailbox/§"),
|
||||
("spoofed", "url", "http://admin/internal/postfix/spoofed/§"),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user