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

fix: ajuste no uso de repo

parent d6e2325b
defmodule NotificationDispatcher.Context.NotificationsContext do
defmodule NotificationDispatcher.Context.NotificationContext do
@moduledoc """
The Notifications context.
"""
......@@ -51,7 +51,7 @@ defmodule NotificationDispatcher.Context.NotificationsContext do
def get_device!(id) do
Device.query_main
|> Device.where(id)
|> Repo.one
|> get_repo().one
end
def get_device(id) do
......@@ -62,7 +62,7 @@ defmodule NotificationDispatcher.Context.NotificationsContext do
def update_device(%Device{} = device, attrs) do
device
|> Device.changeset_update(attrs)
|> Repo.update
|> get_repo().update
end
def create_device(attrs \\ %{}, user_id) do
......@@ -78,7 +78,7 @@ defmodule NotificationDispatcher.Context.NotificationsContext do
%Device{}
|> Device.changeset(attrs)
|> Repo.insert(
|> get_repo().insert(
on_conflict: [
set: [
device_token: attrs["device_token"],
......
defmodule NotificationDispatcher.Controller.NotificationMessageController do
alias NotificationDispatcher.Context.NotificationsContext
alias NotificationDispatcher.Context.NotificationContext
@doc """
Create can return {:ok, notification_message, json} or {:error, changeset}
"""
def create(params) do
case NotificationsContext.create_notification_message(params) do
case NotificationContext.create_notification_message(params) do
{:ok, notification_message} ->
{:ok, notification_message, %{data: %{id: notification_message.id}}}
{:error, changeset} ->
......
......@@ -3,13 +3,13 @@ defmodule NotificationDispatcher.Service.NotificationService do
This module has every function responsible for sending the different types of email on the application
"""
alias NotificationDispatcher.Context.NotificationsContext
alias NotificationDispatcher.Context.NotificationContext
def send_notification(user_id, to, type, params, language, device_id \\ nil) do
notification = NotificationsContext.get_by_type_and_language(type, language)
notification = NotificationContext.get_by_type_and_language(type, language)
notification = if notification == nil do
NotificationsContext.get_by_type(type)
NotificationContext.get_by_type(type)
else
notification
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