small fixes
This commit is contained in:
@@ -38,7 +38,10 @@ websocket_handle({text, Msg}, State) ->
|
|||||||
try jsx:decode(Msg, [return_maps]) of
|
try jsx:decode(Msg, [return_maps]) of
|
||||||
#{<<"action">> := <<"subscribe">>, <<"calendar_id">> := CalendarId} ->
|
#{<<"action">> := <<"subscribe">>, <<"calendar_id">> := CalendarId} ->
|
||||||
io:format("Subscribe to calendar: ~s~n", [CalendarId]),
|
io:format("Subscribe to calendar: ~s~n", [CalendarId]),
|
||||||
NewSubs = [CalendarId | State#state.subscriptions],
|
NewSubs = case lists:member(CalendarId, State#state.subscriptions) of
|
||||||
|
true -> State#state.subscriptions;
|
||||||
|
false -> [CalendarId | State#state.subscriptions]
|
||||||
|
end,
|
||||||
Reply = jsx:encode(#{status => <<"subscribed">>, calendar_id => CalendarId}),
|
Reply = jsx:encode(#{status => <<"subscribed">>, calendar_id => CalendarId}),
|
||||||
io:format("Sending reply: ~s~n", [Reply]),
|
io:format("Sending reply: ~s~n", [Reply]),
|
||||||
{reply, {text, Reply}, State#state{subscriptions = NewSubs}};
|
{reply, {text, Reply}, State#state{subscriptions = NewSubs}};
|
||||||
|
|||||||
@@ -19,16 +19,17 @@ create_calendar(UserId, Title, Description, Confirmation, Type) ->
|
|||||||
{ok, User} ->
|
{ok, User} ->
|
||||||
case User#user.status of
|
case User#user.status of
|
||||||
active ->
|
active ->
|
||||||
% Проверяем подписку для commercial календарей
|
|
||||||
case Type of
|
case Type of
|
||||||
commercial ->
|
commercial ->
|
||||||
case logic_subscription:can_create_commercial_calendar(UserId) of
|
case logic_subscription:can_create_commercial_calendar(UserId) of
|
||||||
true -> ok;
|
true ->
|
||||||
false -> {error, subscription_required}
|
core_calendar:create(UserId, Title, Description, Confirmation, Type);
|
||||||
|
false ->
|
||||||
|
{error, subscription_required}
|
||||||
end;
|
end;
|
||||||
personal -> ok
|
personal ->
|
||||||
end,
|
core_calendar:create(UserId, Title, Description, Confirmation, Type)
|
||||||
core_calendar:create(UserId, Title, Description, Confirmation, Type);
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
{error, user_inactive}
|
{error, user_inactive}
|
||||||
end;
|
end;
|
||||||
|
|||||||
Reference in New Issue
Block a user