prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Alternatives useless after podop
  After updating to master to get all the up-to-date fixes it also moves postfix to use podop and it seems to no longer support receiving external mail from alternative domains 😢 
  
  Sending internal mail between alternatives works as expected but not with external mail, a "relay denied" message is shown in the logs and when checking the postfix podop views it looks like alternative is never mentioned.
  
  </issue>
  <code>
  [start of core/admin/mailu/internal/views/postfix.py]
  1 from mailu import db, models
  2 from mailu.internal import internal
  3 
  4 import flask
  5 
  6 
  7 @internal.route("/postfix/domain/<domain_name>")
  8 def postfix_mailbox_domain(domain_name):
  9     domain = models.Domain.query.get(domain_name) or flask.abort(404)
  10     return flask.jsonify(domain.name)
  11 
  12 
  13 @internal.route("/postfix/mailbox/<email>")
  14 def postfix_mailbox_map(email):
  15     user = models.User.query.get(email) or flask.abort(404)
  16     return flask.jsonify(user.email)
  17 
  18 
  19 @internal.route("/postfix/alias/<alias>")
  20 def postfix_alias_map(alias):
  21     localpart, domain = alias.split('@', 1) if '@' in alias else (None, alias)
  22     alternative = models.Alternative.query.get(domain)
  23     if alternative:
  24         domain = alternative.domain_name
  25     email = '{}@{}'.format(localpart, domain)
  26     if localpart is None:
  27         return flask.jsonify(domain)
  28     else:
  29         alias_obj = models.Alias.resolve(localpart, domain)
  30         if alias_obj:
  31             return flask.jsonify(",".join(alias_obj.destination))
  32         user_obj = models.User.query.get(email)
  33         if user_obj:
  34             return flask.jsonify(user_obj.destination)
  35         return flask.abort(404)
  36 
  37 
  38 @internal.route("/postfix/transport/<email>")
  39 def postfix_transport(email):
  40     localpart, domain = email.split('@', 1) if '@' in email else (None, email)
  41     relay = models.Relay.query.get(domain) or flask.abort(404)
  42     return flask.jsonify("smtp:[{}]".format(relay.smtp))
  43 
  44 
  45 @internal.route("/postfix/sender/<sender>")
  46 def postfix_sender(sender):
  47     """ Simply reject any sender that pretends to be from a local domain
  48     """
  49     localpart, domain_name = sender.split('@', 1) if '@' in sender else (None, sender)
  50     domain = models.Domain.query.get(domain_name)
  51     alternative = models.Alternative.query.get(domain_name)
  52     if domain or alternative:
  53         return flask.jsonify("REJECT")
  54     return flask.abort(404)
  55
  [end of core/admin/mailu/internal/views/postfix.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/core/admin/mailu/internal/views/postfix.py b/core/admin/mailu/internal/views/postfix.py
  --- a/core/admin/mailu/internal/views/postfix.py
  +++ b/core/admin/mailu/internal/views/postfix.py
  @@ -6,7 +6,9 @@
   
   @internal.route("/postfix/domain/<domain_name>")
   def postfix_mailbox_domain(domain_name):
  -    domain = models.Domain.query.get(domain_name) or flask.abort(404)
  +    domain = models.Domain.query.get(domain_name) or \
  +             models.Alternative.query.get(domain_name) or \
  +             flask.abort(404)
       return flask.jsonify(domain.name)
  
verification_info: {"golden_diff": "diff --git a/core/admin/mailu/internal/views/postfix.py b/core/admin/mailu/internal/views/postfix.py\n--- a/core/admin/mailu/internal/views/postfix.py\n+++ b/core/admin/mailu/internal/views/postfix.py\n@@ -6,7 +6,9 @@\n \n @internal.route(\"/postfix/domain/<domain_name>\")\n def postfix_mailbox_domain(domain_name):\n-    domain = models.Domain.query.get(domain_name) or flask.abort(404)\n+    domain = models.Domain.query.get(domain_name) or \\\n+             models.Alternative.query.get(domain_name) or \\\n+             flask.abort(404)\n     return flask.jsonify(domain.name)\n", "issue": "Alternatives useless after podop\nAfter updating to master to get all the up-to-date fixes it also moves postfix to use podop and it seems to no longer support receiving external mail from alternative domains \ud83d\ude22 \r\n\r\nSending internal mail between alternatives works as expected but not with external mail, a \"relay denied\" message is shown in the logs and when checking the postfix podop views it looks like alternative is never mentioned.\n", "before_files": [{"content": "from mailu import db, models\nfrom mailu.internal import internal\n\nimport flask\n\n\n@internal.route(\"/postfix/domain/<domain_name>\")\ndef postfix_mailbox_domain(domain_name):\n    domain = models.Domain.query.get(domain_name) or flask.abort(404)\n    return flask.jsonify(domain.name)\n\n\n@internal.route(\"/postfix/mailbox/<email>\")\ndef postfix_mailbox_map(email):\n    user = models.User.query.get(email) or flask.abort(404)\n    return flask.jsonify(user.email)\n\n\n@internal.route(\"/postfix/alias/<alias>\")\ndef postfix_alias_map(alias):\n    localpart, domain = alias.split('@', 1) if '@' in alias else (None, alias)\n    alternative = models.Alternative.query.get(domain)\n    if alternative:\n        domain = alternative.domain_name\n    email = '{}@{}'.format(localpart, domain)\n    if localpart is None:\n        return flask.jsonify(domain)\n    else:\n        alias_obj = models.Alias.resolve(localpart, domain)\n        if alias_obj:\n            return flask.jsonify(\",\".join(alias_obj.destination))\n        user_obj = models.User.query.get(email)\n        if user_obj:\n            return flask.jsonify(user_obj.destination)\n        return flask.abort(404)\n\n\n@internal.route(\"/postfix/transport/<email>\")\ndef postfix_transport(email):\n    localpart, domain = email.split('@', 1) if '@' in email else (None, email)\n    relay = models.Relay.query.get(domain) or flask.abort(404)\n    return flask.jsonify(\"smtp:[{}]\".format(relay.smtp))\n\n\n@internal.route(\"/postfix/sender/<sender>\")\ndef postfix_sender(sender):\n    \"\"\" Simply reject any sender that pretends to be from a local domain\n    \"\"\"\n    localpart, domain_name = sender.split('@', 1) if '@' in sender else (None, sender)\n    domain = models.Domain.query.get(domain_name)\n    alternative = models.Alternative.query.get(domain_name)\n    if domain or alternative:\n        return flask.jsonify(\"REJECT\")\n    return flask.abort(404)\n", "path": "core/admin/mailu/internal/views/postfix.py"}]}