fix(api): resolve public calendar GET by unique short_name.
CI / test (push) Successful in 7m28s
CI / deploy-ift (push) Successful in 2m46s
CI / e2e-ift (push) Successful in 1m26s
CI / deploy-stage (push) Successful in 2m4s
CI / e2e-stage (push) Successful in 2m4s

This commit is contained in:
2026-08-14 15:00:41 +03:00
parent 658cbda4fe
commit 3d7ae0d372
8 changed files with 67 additions and 18 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ calendar_has_content(CalendarId) ->
%% Получение календаря с проверкой доступа
get_calendar(UserId, CalendarId) ->
case core_calendar:get_by_id(CalendarId) of
case core_calendar:get_by_id_or_short_name(CalendarId) of
{ok, Calendar} ->
case can_access(UserId, Calendar) of
true -> {ok, Calendar};
+5 -6
View File
@@ -15,7 +15,7 @@
-spec follow(UserId :: binary(), CalendarId :: binary()) ->
{ok, #calendar_follow{}} | {error, term()}.
follow(UserId, CalendarId) ->
case core_calendar:get_by_id(CalendarId) of
case core_calendar:get_by_id_or_short_name(CalendarId) of
{error, not_found} ->
{error, not_found};
{ok, #calendar{owner_id = UserId}} ->
@@ -27,7 +27,7 @@ follow(UserId, CalendarId) ->
true ->
case Calendar#calendar.status of
active ->
core_calendar_follow:follow(CalendarId, UserId);
core_calendar_follow:follow(Calendar#calendar.id, UserId);
_ ->
{error, not_found}
end
@@ -40,14 +40,13 @@ follow(UserId, CalendarId) ->
%%%-------------------------------------------------------------------
-spec unfollow(UserId :: binary(), CalendarId :: binary()) -> ok | {error, term()}.
unfollow(UserId, CalendarId) ->
case core_calendar:get_by_id(CalendarId) of
case core_calendar:get_by_id_or_short_name(CalendarId) of
{error, not_found} ->
%% всё равно снимаем локальный follow, если был
core_calendar_follow:unfollow(CalendarId, UserId);
{ok, #calendar{owner_id = UserId}} ->
{error, own_calendar};
{ok, _} ->
core_calendar_follow:unfollow(CalendarId, UserId)
{ok, Calendar} ->
core_calendar_follow:unfollow(Calendar#calendar.id, UserId)
end.
%%%-------------------------------------------------------------------
+2 -5
View File
@@ -10,12 +10,9 @@
-spec list(ActorId :: binary(), CalendarId :: binary()) ->
{ok, [#calendar_specialist{}]} | {error, not_found | access_denied}.
list(ActorId, CalendarId) ->
case core_calendar:get_by_id(CalendarId) of
case logic_calendar:get_calendar(ActorId, CalendarId) of
{ok, Cal} ->
case logic_calendar:can_access(ActorId, Cal) of
true -> {ok, core_calendar_specialist:list_by_calendar(CalendarId)};
false -> {error, access_denied}
end;
{ok, core_calendar_specialist:list_by_calendar(Cal#calendar.id)};
Error -> Error
end.
+4 -4
View File
@@ -25,7 +25,7 @@ create_event(UserId, CalendarId, Title, StartTime, Duration, Description) ->
{reject, Words} ->
{error, {content_banned, Words}};
{ok, Action, [Title2, Desc2], Words} ->
case core_event:create(CalendarId, Title2, StartTime, Duration) of
case core_event:create(Calendar#calendar.id, Title2, StartTime, Duration) of
{ok, Event} ->
case Desc2 of
<<>> -> ok;
@@ -64,7 +64,7 @@ create_recurring_event(UserId, CalendarId, Title, StartTime, Duration, RRule, De
{reject, Words} ->
{error, {content_banned, Words}};
{ok, Action, [Title2, Desc2], Words} ->
case core_event:create_recurring(CalendarId, Title2, StartTime, Duration, RRule) of
case core_event:create_recurring(Calendar#calendar.id, Title2, StartTime, Duration, RRule) of
{ok, Event} ->
case Desc2 of
<<>> -> ok;
@@ -184,8 +184,8 @@ get_event(UserId, EventId) ->
%% Список событий календаря
list_events(UserId, CalendarId) ->
case logic_calendar:get_calendar(UserId, CalendarId) of
{ok, _} ->
core_event:list_by_calendar(CalendarId);
{ok, Calendar} ->
core_event:list_by_calendar(Calendar#calendar.id);
Error ->
Error
end.