Couple of fixes, and introducing Explore section
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -7,6 +7,8 @@ defmodule MobilizonWeb.API.Utils do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Formatter
|
||||
|
||||
@ap_public "https://www.w3.org/ns/activitystreams#Public"
|
||||
|
||||
@doc """
|
||||
Determines the full audience based on mentions for a public audience
|
||||
|
||||
@@ -16,7 +18,7 @@ defmodule MobilizonWeb.API.Utils do
|
||||
"""
|
||||
@spec get_to_and_cc(Actor.t(), list(), map(), String.t()) :: {list(), list()}
|
||||
def get_to_and_cc(%Actor{} = actor, mentions, inReplyTo, :public) do
|
||||
to = ["https://www.w3.org/ns/activitystreams#Public" | mentions]
|
||||
to = [@ap_public | mentions]
|
||||
cc = [actor.followers_url]
|
||||
|
||||
if inReplyTo do
|
||||
@@ -36,7 +38,7 @@ defmodule MobilizonWeb.API.Utils do
|
||||
@spec get_to_and_cc(Actor.t(), list(), map(), String.t()) :: {list(), list()}
|
||||
def get_to_and_cc(%Actor{} = actor, mentions, inReplyTo, :unlisted) do
|
||||
to = [actor.followers_url | mentions]
|
||||
cc = ["https://www.w3.org/ns/activitystreams#Public"]
|
||||
cc = [@ap_public]
|
||||
|
||||
if inReplyTo do
|
||||
{Enum.uniq([inReplyTo.actor | to]), cc}
|
||||
@@ -49,7 +51,7 @@ defmodule MobilizonWeb.API.Utils do
|
||||
Determines the full audience based on mentions based on a private audience
|
||||
|
||||
Audience is:
|
||||
* `to` : the mentionned actors, actor's followers and the eventual actor we're replying to
|
||||
* `to` : the mentioned actors, actor's followers and the eventual actor we're replying to
|
||||
* `cc` : none
|
||||
"""
|
||||
@spec get_to_and_cc(Actor.t(), list(), map(), String.t()) :: {list(), list()}
|
||||
@@ -62,7 +64,7 @@ defmodule MobilizonWeb.API.Utils do
|
||||
Determines the full audience based on mentions based on a direct audience
|
||||
|
||||
Audience is:
|
||||
* `to` : the mentionned actors and the eventual actor we're replying to
|
||||
* `to` : the mentioned actors and the eventual actor we're replying to
|
||||
* `cc` : none
|
||||
"""
|
||||
@spec get_to_and_cc(Actor.t(), list(), map(), String.t()) :: {list(), list()}
|
||||
|
||||
@@ -35,6 +35,7 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Event do
|
||||
{:address, address_id} <-
|
||||
{:address, get_address(object["location"])},
|
||||
{:tags, tags} <- {:tags, fetch_tags(object["tag"])},
|
||||
{:visibility, visibility} <- {:visibility, get_visibility(object)},
|
||||
{:options, options} <- {:options, get_options(object)} do
|
||||
picture_id =
|
||||
with true <- Map.has_key?(object, "attachment") && length(object["attachment"]) > 0,
|
||||
@@ -59,6 +60,7 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Event do
|
||||
"begins_on" => object["startTime"],
|
||||
"ends_on" => object["endTime"],
|
||||
"category" => object["category"],
|
||||
"visibility" => visibility,
|
||||
"join_options" => object["joinOptions"],
|
||||
"url" => object["id"],
|
||||
"uuid" => object["uuid"],
|
||||
@@ -148,6 +150,16 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Event do
|
||||
end)
|
||||
end
|
||||
|
||||
@ap_public "https://www.w3.org/ns/activitystreams#Public"
|
||||
|
||||
defp get_visibility(object) do
|
||||
cond do
|
||||
@ap_public in object["to"] -> :public
|
||||
@ap_public in object["cc"] -> :unlisted
|
||||
true -> :private
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Convert an event struct to an ActivityStream representation
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user