fix: persist specialist_id on event create; 402 commercial without active sub. Fixes EventHub/EventHubBack#61
CI / test (push) Failing after 6m52s
CI / deploy-ift (push) Has been skipped
CI / e2e-ift (push) Has been skipped
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

This commit is contained in:
2026-07-27 21:17:15 +03:00
parent edb7c20f70
commit 81728301e2
9 changed files with 115 additions and 54 deletions
+11 -15
View File
@@ -117,23 +117,20 @@ create_calendar(Req) ->
Confirmation = parse_confirmation(maps:get(<<"confirmation">>, Decoded, <<"manual">>)),
Tags = maps:get(<<"tags">>, Decoded, []),
Type = parse_type(maps:get(<<"type">>, Decoded, <<"personal">>)),
case Type of
commercial ->
case logic_subscription:can_create_commercial_calendar(UserId) of
true -> ok;
false ->
handler_utils: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
case logic_calendar:create_calendar(UserId, Title, Description, Confirmation, Type) of
{ok, Calendar} ->
Updates = [{tags, Tags}, {type, Type}],
core_calendar:update(Calendar#calendar.id, Updates),
{ok, Updated} = core_calendar:get_by_id(Calendar#calendar.id),
Updated = case Tags of
[] -> Calendar;
_ ->
case logic_calendar:update_calendar(UserId, Calendar#calendar.id, [{tags, Tags}]) of
{ok, C2} -> C2;
_ -> Calendar
end
end,
Response = calendar_to_json(Updated),
handler_utils:send_json(Req2, 201, Response);
{error, subscription_required} ->
handler_utils:send_error(Req2, 402, <<"Subscription required for commercial calendar">>);
{error, user_inactive} ->
handler_utils:send_error(Req2, 403, <<"User account is not active">>);
{error, {content_banned, _Words}} ->
@@ -147,7 +144,6 @@ create_calendar(Req) ->
_ ->
handler_utils:send_error(Req2, 400, <<"Invalid JSON">>)
catch
throw:stop -> ok;
_:_ -> handler_utils:send_error(Req2, 400, <<"Invalid JSON format">>)
end;
{error, Code, Message, Req1} ->