Add GET /api/setting/domains
This commit is contained in:
parent
77bf9537d0
commit
12f7485cb1
28
README.md
28
README.md
|
@ -1393,7 +1393,33 @@ Return user setting
|
||||||
"notification": true,
|
"notification": true,
|
||||||
"random_alias_default_domain": "sl.local"
|
"random_alias_default_domain": "sl.local"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### GET /api/setting/domains
|
||||||
|
|
||||||
|
Return domains that user can use to create random alias
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
[
|
||||||
|
true,
|
||||||
|
"d1.test"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
true,
|
||||||
|
"d2.test"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
true,
|
||||||
|
"sl.local"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
false,
|
||||||
|
"ab.cd"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Misc endpoints
|
### Misc endpoints
|
||||||
#### POST /api/apple/process_payment
|
#### POST /api/apple/process_payment
|
||||||
|
|
|
@ -25,3 +25,18 @@ def get_setting():
|
||||||
user = g.user
|
user = g.user
|
||||||
|
|
||||||
return jsonify(setting_to_dict(user))
|
return jsonify(setting_to_dict(user))
|
||||||
|
|
||||||
|
|
||||||
|
@api_bp.route("/setting/domains")
|
||||||
|
@require_api_auth
|
||||||
|
def get_available_domains_for_random_alias():
|
||||||
|
"""
|
||||||
|
Available domains for random alias
|
||||||
|
"""
|
||||||
|
user = g.user
|
||||||
|
|
||||||
|
ret = [
|
||||||
|
(is_sl, domain) for is_sl, domain in user.available_domains_for_random_alias()
|
||||||
|
]
|
||||||
|
|
||||||
|
return jsonify(ret)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from app.models import CustomDomain
|
||||||
from tests.utils import login
|
from tests.utils import login
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,3 +12,17 @@ def test_get_setting(flask_client):
|
||||||
"notification": True,
|
"notification": True,
|
||||||
"random_alias_default_domain": "sl.local",
|
"random_alias_default_domain": "sl.local",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_setting(flask_client):
|
||||||
|
user = login(flask_client)
|
||||||
|
CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True, commit=True)
|
||||||
|
|
||||||
|
r = flask_client.get("/api/setting/domains")
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.json == [
|
||||||
|
[True, "d1.test"],
|
||||||
|
[True, "d2.test"],
|
||||||
|
[True, "sl.local"],
|
||||||
|
[False, "ab.cd"],
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in New Issue