mirror of
https://github.com/Mailu/Mailu.git
synced 2024-12-14 10:53:30 +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
|
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>")
|
@internal.route("/postfix/alias/<alias>")
|
||||||
def postfix_alias_map(alias):
|
def postfix_alias_map(alias):
|
||||||
localpart, domain = alias.split('@', 1) if '@' in alias else (None, 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
|
domain = alternative.domain_name
|
||||||
email = '{}@{}'.format(localpart, domain)
|
email = '{}@{}'.format(localpart, domain)
|
||||||
if localpart is None:
|
if localpart is None:
|
||||||
return domain
|
return flask.jsonify(domain)
|
||||||
else:
|
else:
|
||||||
alias_obj = models.Alias.resolve(localpart, domain)
|
alias_obj = models.Alias.resolve(localpart, domain)
|
||||||
if alias_obj:
|
if alias_obj:
|
||||||
return alias_obj.destination
|
return flask.jsonify(alias_obj.destination)
|
||||||
user_obj = models.User.query.get(email)
|
user_obj = models.User.query.get(email)
|
||||||
if user_obj:
|
if user_obj:
|
||||||
return user_obj.destination
|
return flask.jsonify(user_obj.destination)
|
||||||
flask.abort(404)
|
return flask.abort(404)
|
||||||
|
|
||||||
|
|
||||||
@internal.route("/postfix/alias/domain/<domain>")
|
@internal.route("/postfix/spoofed/<email>")
|
||||||
def postfix_alias_domain(domain):
|
def postfix_spoofed(email):
|
||||||
pass
|
return flask.abort(404)
|
||||||
|
|
||||||
|
|
||||||
@internal.route("/postfix/alias/map/<alias>")
|
@internal.route("/postfix/transport/<email>")
|
||||||
def postfix_alias_map(alias):
|
def postfix_transport(email):
|
||||||
pass
|
return flask.abort(404)
|
||||||
|
|
||||||
|
|
||||||
@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("/dovecot/auth/passdb/<user_email>")
|
@internal.route("/dovecot/auth/passdb/<user_email>")
|
||||||
|
@ -268,7 +268,7 @@ class User(Base, Email):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def destination(self):
|
def destination(self):
|
||||||
if self.foward_enabled:
|
if self.forward_enabled:
|
||||||
result = self.self.forward_destination
|
result = self.self.forward_destination
|
||||||
if self.forward_keep:
|
if self.forward_keep:
|
||||||
result += ',' + self.email
|
result += ',' + self.email
|
||||||
@ -339,13 +339,13 @@ class Alias(Base, Email):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def resolve(cls, localpart, domain_name):
|
def resolve(cls, localpart, domain_name):
|
||||||
return cls.query.filter(
|
return cls.query.filter(
|
||||||
sqlalchemy._and(cls.domain_name == domain_name,
|
sqlalchemy.and_(cls.domain_name == domain_name,
|
||||||
sqlalchemy._or(
|
sqlalchemy.or_(
|
||||||
cls.localpart == localpart,
|
cls.localpart == localpart,
|
||||||
cls.wildcard.like(localpart)
|
cls.wildcard.like(localpart)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
).first()
|
||||||
|
|
||||||
|
|
||||||
class Token(Base):
|
class Token(Base):
|
||||||
|
@ -15,7 +15,7 @@ def start_podop():
|
|||||||
run_server(40, "postfix", "/tmp/podop.socket", [
|
run_server(40, "postfix", "/tmp/podop.socket", [
|
||||||
("transport", "url", "http://admin/internal/postfix/transport/§"),
|
("transport", "url", "http://admin/internal/postfix/transport/§"),
|
||||||
("alias", "url", "http://admin/internal/postfix/alias/§"),
|
("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/§"),
|
("mailbox", "url", "http://admin/internal/postfix/mailbox/§"),
|
||||||
("spoofed", "url", "http://admin/internal/postfix/spoofed/§"),
|
("spoofed", "url", "http://admin/internal/postfix/spoofed/§"),
|
||||||
])
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user