This commit is contained in:
2026-04-21 16:35:05 +03:00
parent a4a7daa5e0
commit 3b73439b49
11 changed files with 981 additions and 2 deletions

View File

@@ -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;