liquid_feedback_frontend
view app/main/api/_member.lua @ 1311:94cb2525c48c
Added missing font files
| author | bsw | 
|---|---|
| date | Wed Aug 01 16:49:11 2018 +0200 (2018-08-01) | 
| parents | 32cc544d5a5b | 
| children | 2a0d86117d54 | 
 line source
     1 local members = param.get("members", "table")
     3 local include_profile = param.get("include_profile", atom.boolean)
     5 if include_profile and not app.scopes.read_profiles then
     6   return util.api_error(403, "Forbidden", "insufficient_scope", "Scope read_profiles required")
     7 end
     9 local fields = {}
    11 if app.scopes.read_authors or app.scopes.read_identities then
    12   fields = { "id", "created", "last_activity", "admin", "name", "location" }
    13 end
    15 if app.scopes.read_identities then
    16   fields[#fields+1] = "identification"
    17 end
    19 local r = json.array()
    21 if app.scopes.read_identities then
    23   if include_profile then
    24     members:load("profile")
    25   end
    27   for i, member in ipairs(members) do
    28     local m = json.object()
    29     for j, field in ipairs(fields) do
    30       local value = member[field]
    31       if value == nil then
    32         value = json.null
    33       else
    34         value = tostring(value)
    35       end
    36       m[field] = value
    37     end
    38     if include_profile then
    39       m.profile = execute.chunk{ module = "api", chunk = "_profile", params = { profile = member.profile } }
    40     end
    41     r[#r+1] = m
    42   end
    43 end
    45 return r
