liquid_feedback_frontend
view app/main/api/application.lua @ 1820:2e5b303ea68e
Better handling of use terms, added view for privacy policy
| author | bsw | 
|---|---|
| date | Wed Jan 26 00:33:21 2022 +0100 (2022-01-26) | 
| parents | fa82e72afdfe | 
| children | 
 line source
     1 slot.set_layout(nil, "application/json")
     3 local r = json.array()
     5 local system_applications = SystemApplication:get_all()
     7 local base_url = request.get_absolute_baseurl()
     9 if string.sub(base_url, -1, -1) == "/" then
    10   base_url = string.sub(base_url, 1, -2)
    11 end
    13 r[#r+1] = json.object{
    14   type = "system",
    15   name = "LiquidFeedback",
    16   base_url = base_url,
    17   manifest_url = request.get_absolute_baseurl() .. "api/1/info",
    18   cert_common_name = config.oauth2.cert_common_name
    19 }
    21 for i, system_application in ipairs(system_applications) do
    22   r[#r+1] = json.object{
    23     type = "system",
    24     name = system_application.name,
    25     base_url = system_application.base_url,
    26     manifest_url = system_application.manifest_url,
    27     cert_common_name = system_application.cert_common_name
    28   }
    29 end
    31 if app.access_token then
    33   local member_applications = MemberApplication:by_member_id_with_domain(app.access_token.member_id)
    35   for i, member_application in ipairs(member_applications) do
    36     r[#r+1] = json.object{
    37       type = "dynamic",
    38       name = "https://" .. member_application.domain .. "/",
    39       base_url = "https://" .. member_application.domain .. "/",
    40       manifest_url = "https://" .. member_application.domain .. "/" .. config.oauth2.manifest_magic
    41     }
    42   end
    44 end
    46 slot.put_into("data", json.export(json.object{ result = r }))
