small fixes
This commit is contained in:
@@ -38,7 +38,10 @@ websocket_handle({text, Msg}, State) ->
|
||||
try jsx:decode(Msg, [return_maps]) of
|
||||
#{<<"action">> := <<"subscribe">>, <<"calendar_id">> := 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}),
|
||||
io:format("Sending reply: ~s~n", [Reply]),
|
||||
{reply, {text, Reply}, State#state{subscriptions = NewSubs}};
|
||||
|
||||
Reference in New Issue
Block a user