Add address input and refactor federation stuff
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -15,7 +15,8 @@ defmodule MobilizonWeb.API.Comments do
|
||||
|
||||
Creates a comment from an actor and a status
|
||||
"""
|
||||
@spec create_comment(String.t(), String.t(), String.t()) :: {:ok, Activity.t()} | any()
|
||||
@spec create_comment(String.t(), String.t(), String.t()) ::
|
||||
{:ok, Activity.t(), Comment.t()} | any()
|
||||
def create_comment(
|
||||
from_username,
|
||||
status,
|
||||
|
||||
@@ -2,6 +2,7 @@ defmodule MobilizonWeb.API.Events do
|
||||
@moduledoc """
|
||||
API for Events
|
||||
"""
|
||||
alias Mobilizon.Addresses
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
@@ -11,7 +12,7 @@ defmodule MobilizonWeb.API.Events do
|
||||
@doc """
|
||||
Create an event
|
||||
"""
|
||||
@spec create_event(map()) :: {:ok, Activity.t()} | any()
|
||||
@spec create_event(map()) :: {:ok, Activity.t(), Event.t()} | any()
|
||||
def create_event(
|
||||
%{
|
||||
title: title,
|
||||
@@ -22,10 +23,9 @@ defmodule MobilizonWeb.API.Events do
|
||||
tags: tags
|
||||
} = args
|
||||
) do
|
||||
require Logger
|
||||
|
||||
with %Actor{url: url} = actor <-
|
||||
Actors.get_local_actor_with_everything(organizer_actor_id),
|
||||
physical_address <- Map.get(args, :physical_address, nil),
|
||||
title <- String.trim(title),
|
||||
visibility <- Map.get(args, :visibility, :public),
|
||||
picture <- Map.get(args, :picture, nil),
|
||||
@@ -34,14 +34,12 @@ defmodule MobilizonWeb.API.Events do
|
||||
event <-
|
||||
ActivityPubUtils.make_event_data(
|
||||
url,
|
||||
to,
|
||||
%{to: to, cc: cc},
|
||||
title,
|
||||
content_html,
|
||||
picture,
|
||||
tags,
|
||||
cc,
|
||||
%{begins_on: begins_on},
|
||||
category
|
||||
%{begins_on: begins_on, physical_address: physical_address, category: category}
|
||||
) do
|
||||
ActivityPub.create(%{
|
||||
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
@@ -51,4 +49,15 @@ defmodule MobilizonWeb.API.Events do
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
defp get_physical_address(address_id) when is_number(address_id),
|
||||
do: Addresses.get_address!(address_id)
|
||||
|
||||
defp get_physical_address(address_id) when is_binary(address_id) do
|
||||
with {address_id, ""} <- Integer.parse(address_id) do
|
||||
get_physical_address(address_id)
|
||||
end
|
||||
end
|
||||
|
||||
defp get_physical_address(nil), do: nil
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ defmodule MobilizonWeb.API.Groups do
|
||||
@doc """
|
||||
Create a group
|
||||
"""
|
||||
@spec create_group(map()) :: {:ok, Activity.t()} | any()
|
||||
@spec create_group(map()) :: {:ok, Activity.t(), Group.t()} | any()
|
||||
def create_group(
|
||||
%{
|
||||
preferred_username: title,
|
||||
|
||||
Reference in New Issue
Block a user