Commit d6e2325b authored by Miguel Basticioto's avatar Miguel Basticioto
Browse files

Merge branch 'master' into dev

# Conflicts:
#	lib/contexts/notifications_context.ex
parents 5aabfc1d 9a4dcf06
......@@ -28,3 +28,4 @@ notification_dispatcher-*.tar
notification_dispatcher.iml
.idea
mix.lock
......@@ -20,4 +20,20 @@ defmodule NotificationDispatcher.Migration do
create index(:notification_messages, [:notification_type])
end
def create_devices() do
create table(:devices, primary_key: false) do
add :id, :uuid, primary_key: true
add :user_id, :uuid, null: false
add :device_token, :text, null: false
add :os, :integer
timestamps()
end
create index(:devices, :user_id)
create unique_index(:devices, :device_token)
create index(:devices, :os)
end
end
\ No newline at end of file
defmodule NotificationDispatcher.Schema.Device do
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query, warn: false
alias NotificationDispatcher.Schema.Device
@primary_key {:id, :binary_id, autogenerate: true}
schema "devices" do
field :device_token, :string
field :user_id, :binary_id
field :os, :integer
timestamps()
end
@doc false
def changeset(device, attrs) do
device
|> cast(attrs, [:user_id, :device_token, :os])
|> validate_required([:user_id, :device_token, :os])
end
def changeset_update(device, attrs) do
device
|> cast(attrs, [:device_token])
|> validate_required([])
end
@doc false
def query_main, do: from(device in Device, as: :device)
def where(query, id), do: from([device: d] in query, where: d.id == ^id)
def where_user_id_in(query, user_ids), do: from([device: d] in query, where: d.user_id in ^user_ids)
end
defmodule NotificationDispatcher.MixProject do
use Mix.Project
@project_url "https://git.catskillet.com/public-libs/elixir/notification-dispatcher"
def project do
[
app: :notification_dispatcher,
version: "0.1.0",
version: "0.1.2",
elixir: "~> 1.10.2",
start_permanent: Mix.env() == :prod,
deps: deps()
deps: deps(),
package: package(),
description: "Library used for integration with the rabbitmq for dispatching notification messages to consuming services."
]
end
defp package do
[
licenses: ["MIT"],
links: %{"GitLab" => @project_url},
]
end
......@@ -25,6 +35,7 @@ defmodule NotificationDispatcher.MixProject do
{:amqp, "~> 1.6.0"},
{:poison, "~> 3.1"},
{:timex, "~> 3.5"},
{:ex_doc, "~> 0.23", only: :dev, runtime: false}
]
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment