bump_server/lib/bump_web/controllers/message_controller.ex
raphael d2fe15d3ae adds message title, adds sender delete
- message now contains a second string
  which is meant for unencrypted title
  information, which can be displayed
  without e2e encryption.
- senders can now be deleted
- the same sender / token connection is
  no longer added to the database
2022-01-03 13:07:33 +01:00

40 lines
912 B
Elixir

defmodule BumpWeb.MessageController do
use BumpWeb, :controller
alias Bump.Messages
alias Bump.Senders
def index(conn, _params) do
text conn, "Bump Api"
end
def list(conn, %{"sender" => sender, "minutes" => minutes}) do
list = Messages.list(sender, String.to_integer(minutes))
text conn, Jason.encode!(%{"messages" => list})
end
def clear(conn, %{"sender" => sender}) do
Messages.clear(sender)
text conn, Jason.encode!(%{"status" => "OK"})
end
def push(conn, %{"sender" => sender, "title"=> title, "data" => data}) do
Messages.push(sender, title, data)
text conn, Jason.encode!(%{"status" => "OK"})
end
def pop(conn, %{"sender" => sender}) do
message = Messages.pop(sender)
text conn, Jason.encode!(message)
end
def peek(conn, %{"sender" => sender}) do
message = Messages.peek(sender)
text conn, Jason.encode!(message)
end
end