Skip to content

Commit

Permalink
Cleanup type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
noah-schechter committed Dec 27, 2024
1 parent ed73522 commit 906bb46
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions platform/lib/platform/updates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -308,27 +308,12 @@ defmodule Platform.Updates do
@doc """
Helper API function that takes attribute change information and uses it to create an Update changeset. Requires 'explanation' to be in attrs.
"""
def change_from_media_creation(media, user_or_token)

def change_from_media_creation(%Media{} = media, %User{} = user) do
def change_from_media_creation(%Media{} = media, user_or_token) when is_struct(user_or_token, User) or is_struct(user_or_token, APIToken) do
change_update(
%Update{},
media,
user,
%{
"type" => :create
}
)
end

def change_from_media_creation(%Media{} = media, %APIToken{} = api_token) do
change_update(
%Update{},
media,
api_token,
%{
"type" => :create
}
user_or_token,
%{"type" => :create}
)
end

Expand Down

0 comments on commit 906bb46

Please sign in to comment.