feat(share): calendar_share invite/ACL for personal and commercial.
Co-editor and deputy grants with mirror_to_default; personal out of search; list owned+shared. Refs EventHub/EventHubBack#73
This commit is contained in:
@@ -168,7 +168,7 @@ list_calendars(Req) ->
|
||||
{ok, UserId, Req1} ->
|
||||
case logic_calendar:list_calendars(UserId) of
|
||||
{ok, Calendars} ->
|
||||
Response = [calendar_to_json(C) || C <- Calendars],
|
||||
Response = [calendar_list_json(UserId, C) || C <- Calendars],
|
||||
handler_utils:send_json(Req1, 200, Response);
|
||||
{error, _} ->
|
||||
handler_utils:send_error(Req1, 500, <<"Internal server error">>)
|
||||
@@ -181,6 +181,21 @@ list_calendars(Req) ->
|
||||
%%% Внутренние функции
|
||||
%%%===================================================================
|
||||
|
||||
-spec calendar_list_json(binary(), #calendar{}) -> map().
|
||||
calendar_list_json(UserId, #calendar{owner_id = UserId} = Calendar) ->
|
||||
(calendar_to_json(Calendar))#{role => <<"owner">>};
|
||||
calendar_list_json(UserId, Calendar) ->
|
||||
Base = (calendar_to_json(Calendar))#{role => <<"shared">>},
|
||||
case core_calendar_share:get(Calendar#calendar.id, UserId) of
|
||||
{ok, Share} ->
|
||||
Base#{
|
||||
share_rights => Share#calendar_share.rights,
|
||||
mirror_to_default => Share#calendar_share.mirror_to_default
|
||||
};
|
||||
{error, not_found} ->
|
||||
Base
|
||||
end.
|
||||
|
||||
-spec calendar_to_json(#calendar{}) -> map().
|
||||
calendar_to_json(Calendar) ->
|
||||
Base = handler_utils:calendar_to_json(Calendar),
|
||||
|
||||
Reference in New Issue
Block a user