Stage 8
This commit is contained in:
@@ -27,6 +27,18 @@ create_calendar(Req) ->
|
||||
Tags = maps:get(<<"tags">>, Decoded, []),
|
||||
Type = parse_type(maps:get(<<"type">>, Decoded, <<"personal">>)),
|
||||
|
||||
% Проверяем подписку для commercial календарей ДО создания
|
||||
case Type of
|
||||
commercial ->
|
||||
case logic_subscription:can_create_commercial_calendar(UserId) of
|
||||
true -> ok;
|
||||
false ->
|
||||
send_error(Req2, 402, <<"Subscription required for commercial calendar">>),
|
||||
throw(stop)
|
||||
end;
|
||||
personal -> ok
|
||||
end,
|
||||
|
||||
case logic_calendar:create_calendar(UserId, Title, Description, Confirmation) of
|
||||
{ok, Calendar} ->
|
||||
% Обновляем теги и тип
|
||||
@@ -46,6 +58,7 @@ create_calendar(Req) ->
|
||||
_ ->
|
||||
send_error(Req2, 400, <<"Invalid JSON">>)
|
||||
catch
|
||||
throw:stop -> ok; % Уже отправили ошибку
|
||||
_:_ ->
|
||||
send_error(Req2, 400, <<"Invalid JSON format">>)
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user