2021-12-05 00:36:13 +01:00
|
|
|
defmodule Bump.Messages do
|
2021-12-30 13:06:26 +01:00
|
|
|
alias Bump.Database
|
|
|
|
alias Bump.Firebase
|
2021-12-05 00:36:13 +01:00
|
|
|
|
2021-12-10 15:34:38 +01:00
|
|
|
def pop(sender) do
|
2021-12-30 16:11:53 +01:00
|
|
|
Database.pop(sender)
|
2021-12-10 15:34:38 +01:00
|
|
|
end
|
|
|
|
|
2021-12-17 16:23:48 +01:00
|
|
|
def peek(sender) do
|
2021-12-30 13:06:26 +01:00
|
|
|
Database.peek(sender)
|
2021-12-05 00:36:13 +01:00
|
|
|
end
|
|
|
|
|
2021-12-10 15:34:38 +01:00
|
|
|
def list(sender, minutes) do
|
2021-12-30 13:06:26 +01:00
|
|
|
Database.list(sender, minutes)
|
2021-12-05 00:36:13 +01:00
|
|
|
end
|
|
|
|
|
2021-12-10 15:34:38 +01:00
|
|
|
def clear(sender) do
|
2021-12-30 13:06:26 +01:00
|
|
|
Database.clear(sender)
|
2021-12-05 00:36:13 +01:00
|
|
|
end
|
|
|
|
|
2022-01-03 13:07:33 +01:00
|
|
|
def push(sender, title, data) do
|
|
|
|
Database.push(sender, title, data)
|
2021-12-30 16:23:54 +01:00
|
|
|
tokens = Database.tokens(sender)
|
|
|
|
|
|
|
|
for token <- tokens do
|
2022-01-03 13:07:33 +01:00
|
|
|
Firebase.push(%{"firebase_token" => token.firebase_token, "title" => title, "data" => data})
|
2021-12-30 16:23:54 +01:00
|
|
|
end
|
2021-12-05 00:36:13 +01:00
|
|
|
end
|
|
|
|
|
2021-12-10 12:46:34 +01:00
|
|
|
|
2021-12-05 00:36:13 +01:00
|
|
|
end
|