Fix all warnings
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
d9f29e7d7b
commit
608105cc31
@ -6,9 +6,8 @@ defmodule Mix.Tasks.CreateBot do
|
||||
use Mix.Task
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Bot
|
||||
alias Mobilizon.Repo
|
||||
alias Mobilizon.Actors.User
|
||||
import Logger
|
||||
require Logger
|
||||
|
||||
@shortdoc "Register user"
|
||||
def run([email, name, summary, type, url]) do
|
||||
|
@ -6,9 +6,6 @@ defmodule Mix.Tasks.Toot do
|
||||
use Mix.Task
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Repo
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Events.Comment
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
require Logger
|
||||
|
@ -17,7 +17,6 @@ defmodule Mobilizon.Actors.Actor do
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.{Actor, User, Follower, Member}
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
import Ecto.Query
|
||||
alias Mobilizon.Repo
|
||||
@ -105,7 +104,7 @@ defmodule Mobilizon.Actors.Actor do
|
||||
end
|
||||
|
||||
# TODO : Use me !
|
||||
@email_regex ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
|
||||
# @email_regex ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
|
||||
def remote_actor_creation(params) do
|
||||
changes =
|
||||
%Actor{}
|
||||
@ -279,7 +278,7 @@ defmodule Mobilizon.Actors.Actor do
|
||||
end
|
||||
end
|
||||
|
||||
defp do_follow(%Actor{} = follower, %Actor{} = followed, approved \\ true) do
|
||||
defp do_follow(%Actor{} = follower, %Actor{} = followed, approved) do
|
||||
Actors.create_follower(%{
|
||||
"actor_id" => follower.id,
|
||||
"target_actor_id" => followed.id,
|
||||
|
@ -7,7 +7,6 @@ defmodule Mobilizon.Actors do
|
||||
alias Mobilizon.Repo
|
||||
|
||||
alias Mobilizon.Actors.{Actor, Bot, Member, Follower, User}
|
||||
alias Mobilizon.Actors
|
||||
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
@ -63,13 +62,9 @@ defmodule Mobilizon.Actors do
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the first actor found for an user
|
||||
|
||||
Useful when the user has not defined default actor
|
||||
|
||||
Raises `Ecto.NoResultsError` if no Actor is found for this ID
|
||||
"""
|
||||
# Returns the first actor found for an user
|
||||
# Useful when the user has not defined default actor
|
||||
# Raises `Ecto.NoResultsError` if no Actor is found for this ID
|
||||
defp get_first_actor_for_user(%Mobilizon.Actors.User{id: id} = _user) do
|
||||
Repo.one!(from(a in Actor, where: a.user_id == ^id))
|
||||
end
|
||||
@ -195,9 +190,6 @@ defmodule Mobilizon.Actors do
|
||||
Repo.all(User)
|
||||
end
|
||||
|
||||
defp blank?(""), do: nil
|
||||
defp blank?(n), do: n
|
||||
|
||||
def insert_or_update_actor(data, preload \\ false) do
|
||||
cs = Actor.remote_actor_creation(data)
|
||||
|
||||
@ -321,7 +313,6 @@ defmodule Mobilizon.Actors do
|
||||
end
|
||||
|
||||
def get_actor_by_name(name) do
|
||||
actor =
|
||||
case String.split(name, "@") do
|
||||
[name] ->
|
||||
Repo.one(from(a in Actor, where: a.preferred_username == ^name and is_nil(a.domain)))
|
||||
@ -404,7 +395,7 @@ defmodule Mobilizon.Actors do
|
||||
Find actors by their name or displayed name
|
||||
"""
|
||||
def find_actors_by_username_or_name(username, page \\ 1, limit \\ 10)
|
||||
def find_actors_by_username_or_name("", page, limit), do: []
|
||||
def find_actors_by_username_or_name("", _page, _limit), do: []
|
||||
|
||||
def find_actors_by_username_or_name(username, page, limit) do
|
||||
start = (page - 1) * limit
|
||||
@ -421,9 +412,7 @@ defmodule Mobilizon.Actors do
|
||||
)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Sanitize the LIKE queries
|
||||
"""
|
||||
# Sanitize the LIKE queries
|
||||
defp like_sanitize(value) do
|
||||
"%" <> String.replace(value, ~r/([\\%_])/, "\\1") <> "%"
|
||||
end
|
||||
@ -515,7 +504,7 @@ defmodule Mobilizon.Actors do
|
||||
defp handle_actor_user_changeset(changeset) do
|
||||
changeset =
|
||||
Ecto.Changeset.traverse_errors(changeset, fn
|
||||
{msg, opts} -> msg
|
||||
{msg, _opts} -> msg
|
||||
msg -> msg
|
||||
end)
|
||||
|
||||
|
@ -4,7 +4,7 @@ defmodule Mobilizon.Actors.Bot do
|
||||
"""
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
alias Mobilizon.Actors.{Actor, User, Bot}
|
||||
alias Mobilizon.Actors.{Actor, User}
|
||||
|
||||
schema "bots" do
|
||||
field(:source, :string)
|
||||
|
@ -23,7 +23,7 @@ defmodule Mobilizon.Actors.Service.ResetPassword do
|
||||
) do
|
||||
{:ok, user}
|
||||
else
|
||||
err ->
|
||||
_err ->
|
||||
{:error, :invalid_token}
|
||||
end
|
||||
end
|
||||
|
@ -114,9 +114,7 @@ defmodule Mobilizon.Actors.User do
|
||||
|> Base.url_encode64()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Hash password when it's changed
|
||||
"""
|
||||
# Hash password when it's changed
|
||||
defp hash_password(changeset) do
|
||||
case changeset do
|
||||
%Ecto.Changeset{valid?: true, changes: %{password: password}} ->
|
||||
|
@ -5,7 +5,7 @@ defmodule Mobilizon.Addresses.Address do
|
||||
import Ecto.Changeset
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Groups.Group
|
||||
# alias Mobilizon.Actors.Actor
|
||||
|
||||
schema "addresses" do
|
||||
field(:addressCountry, :string)
|
||||
@ -16,8 +16,8 @@ defmodule Mobilizon.Addresses.Address do
|
||||
field(:geom, Geo.PostGIS.Geometry)
|
||||
field(:postalCode, :string)
|
||||
field(:streetAddress, :string)
|
||||
has_one(:event, Event)
|
||||
has_one(:group, Group)
|
||||
has_one(:event, Event, foreign_key: :physical_address_id)
|
||||
# has_one(:group, Actor)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
@ -5,11 +5,10 @@ defmodule Mobilizon.Addresses do
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias Mobilizon.Repo
|
||||
require Logger
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
|
||||
import Logger
|
||||
|
||||
@geom_types [:point]
|
||||
|
||||
@doc """
|
||||
|
@ -215,9 +215,7 @@ defmodule Mobilizon.Events do
|
||||
Repo.all(query)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Sanitize the LIKE queries
|
||||
"""
|
||||
# Sanitize the LIKE queries
|
||||
defp like_sanitize(value) do
|
||||
"%" <> String.replace(value, ~r/([\\%_])/, "\\1") <> "%"
|
||||
end
|
||||
|
@ -21,10 +21,6 @@ defmodule MobilizonWeb.NodeInfoController do
|
||||
|
||||
# Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
|
||||
def nodeinfo(conn, %{"version" => "2.0"}) do
|
||||
import Logger
|
||||
Logger.debug(inspect(@instance))
|
||||
# stats = Stats.get_stats()
|
||||
|
||||
response = %{
|
||||
version: "2.0",
|
||||
software: %{
|
||||
@ -39,12 +35,10 @@ defmodule MobilizonWeb.NodeInfoController do
|
||||
openRegistrations: Keyword.get(@instance, :registrations_open),
|
||||
usage: %{
|
||||
users: %{
|
||||
# total: stats.user_count || 0
|
||||
total: Actors.count_users()
|
||||
},
|
||||
localPosts: Events.count_local_events(),
|
||||
localComments: Events.count_local_comments()
|
||||
# localPosts: stats.status_count || 0
|
||||
},
|
||||
metadata: %{
|
||||
nodeName: Keyword.get(@instance, :name)
|
||||
|
@ -1,6 +1,4 @@
|
||||
defmodule MobilizonWeb.Resolvers.Actor do
|
||||
alias Mobilizon.Actors.Actor, as: ActorSchema
|
||||
alias Mobilizon.Actors.User
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
defmodule MobilizonWeb.Resolvers.Category do
|
||||
require Logger
|
||||
alias Mobilizon.Actors.User
|
||||
|
||||
def list_categories(_parent, _args, _resolution) do
|
||||
categories =
|
||||
@ -13,7 +14,7 @@ defmodule MobilizonWeb.Resolvers.Category do
|
||||
end
|
||||
|
||||
def create_category(_parent, %{title: title, picture: picture, description: description}, %{
|
||||
context: %{current_user: user}
|
||||
context: %{current_user: %User{} = _user}
|
||||
}) do
|
||||
with {:ok, category} <-
|
||||
Mobilizon.Events.create_category(%{
|
||||
@ -35,7 +36,7 @@ defmodule MobilizonWeb.Resolvers.Category do
|
||||
end
|
||||
end
|
||||
|
||||
def create_category(_parent, %{title: title, picture: picture, description: description}, %{}) do
|
||||
def create_category(_parent, _args, %{}) do
|
||||
{:error, "You are not allowed to create a category if not connected"}
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,6 @@
|
||||
defmodule MobilizonWeb.Resolvers.Event do
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Actors
|
||||
|
||||
def list_events(_parent, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_events()}
|
||||
@ -15,10 +16,20 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participant for event (separate request)
|
||||
"""
|
||||
def list_participants_for_event(_parent, %{uuid: uuid}, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participants for event (through an event request)
|
||||
"""
|
||||
def list_participants_for_event(%{uuid: uuid}, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Search events by title
|
||||
"""
|
||||
@ -30,7 +41,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
Search events and actors by title
|
||||
"""
|
||||
def search_events_and_actors(_parent, %{search: search, page: page, limit: limit}, _resolution) do
|
||||
search = String.strip(search)
|
||||
search = String.trim(search)
|
||||
|
||||
found =
|
||||
case String.contains?(search, "@") do
|
||||
@ -52,14 +63,9 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
{:ok, found}
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participants for event (through an event request)
|
||||
"""
|
||||
def list_participants_for_event(%{uuid: uuid}, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
def create_event(_parent, args, %{context: %{current_user: user}}) do
|
||||
organizer_actor_id = Map.get(args, "organizer_actor_id") || Actors.get_actor_for_user(user).id
|
||||
args = args |> Map.put("organizer_actor_id", organizer_actor_id)
|
||||
Mobilizon.Events.create_event(args)
|
||||
end
|
||||
|
||||
|
@ -20,7 +20,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
{:error, "You need to be logged-in to view current user"}
|
||||
end
|
||||
|
||||
@desc """
|
||||
@doc """
|
||||
Login an user. Returns a token and the user
|
||||
"""
|
||||
def login_user(_parent, %{email: email, password: password}, _resolution) do
|
||||
@ -37,7 +37,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
end
|
||||
end
|
||||
|
||||
@desc """
|
||||
@doc """
|
||||
Register an user :
|
||||
- create the user
|
||||
- create the actor
|
||||
@ -111,7 +111,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
end
|
||||
end
|
||||
|
||||
@desc "Change an user default actor"
|
||||
@doc "Change an user default actor"
|
||||
def change_default_actor(_parent, %{preferred_username: username}, %{
|
||||
context: %{current_user: user}
|
||||
}) do
|
||||
|
@ -10,9 +10,6 @@ defmodule MobilizonWeb.Schema do
|
||||
import_types(Absinthe.Type.Custom)
|
||||
import_types(Absinthe.Plug.Types)
|
||||
|
||||
# import_types(MobilizonWeb.Schema.EventTypes)
|
||||
# import_types(MobilizonWeb.Schema.ActorTypes)
|
||||
|
||||
alias MobilizonWeb.Resolvers
|
||||
|
||||
@desc "An ActivityPub actor"
|
||||
|
@ -23,7 +23,7 @@ defmodule MobilizonWeb.Uploaders.Category do
|
||||
end
|
||||
|
||||
# Override the persisted filenames:
|
||||
def filename(version, {file, %{title: title}}) do
|
||||
def filename(version, {_file, %{title: title}}) do
|
||||
"#{title}_#{version}"
|
||||
end
|
||||
|
||||
|
@ -3,14 +3,10 @@ defmodule MobilizonWeb.ActivityPub.ActorView do
|
||||
|
||||
alias MobilizonWeb.ActivityPub.ActorView
|
||||
alias MobilizonWeb.ActivityPub.ObjectView
|
||||
alias MobilizonWeb.WebFinger
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Repo
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Service.ActivityPub.Transmogrifier
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
alias Mobilizon.Activity
|
||||
import Ecto.Query
|
||||
|
||||
def render("actor.json", %{actor: actor}) do
|
||||
public_key = Mobilizon.Service.ActivityPub.Utils.pem_to_public_key_pem(actor.keys)
|
||||
|
@ -1,7 +1,6 @@
|
||||
defmodule MobilizonWeb.ActivityPub.ObjectView do
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.ActivityPub.ObjectView
|
||||
alias Mobilizon.Service.ActivityPub.Transmogrifier
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
|
||||
def render("event.json", %{event: event}) do
|
||||
@ -37,14 +36,14 @@ defmodule MobilizonWeb.ActivityPub.ObjectView do
|
||||
Map.merge(comment, Utils.make_json_ld_header())
|
||||
end
|
||||
|
||||
def render("category.json", %{category: category}) do
|
||||
def render("category.json", %{category: category}) when not is_nil(category) do
|
||||
%{
|
||||
"identifier" => category.id,
|
||||
"name" => category.title
|
||||
}
|
||||
end
|
||||
|
||||
def render("category.json", %{category: nil}) do
|
||||
def render("category.json", %{category: _category}) do
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
@ -153,7 +153,7 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
end
|
||||
end
|
||||
|
||||
def follow(%Actor{} = follower, %Actor{} = followed, activity_id \\ nil, local \\ true) do
|
||||
def follow(%Actor{} = follower, %Actor{} = followed, _activity_id \\ nil, local \\ true) do
|
||||
with {:ok, follow} <- Actor.follow(follower, followed, true),
|
||||
data <- make_follow_data(follower, followed, follow.id),
|
||||
{:ok, activity} <- insert(data, local),
|
||||
@ -197,9 +197,6 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
end
|
||||
end
|
||||
|
||||
def create_public_activities(%Actor{} = actor) do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Create an actor locally by it's URL (AP ID)
|
||||
"""
|
||||
@ -283,7 +280,6 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
"content-length": byte_size(json)
|
||||
})
|
||||
|
||||
{:ok, response} =
|
||||
HTTPoison.post(
|
||||
inbox,
|
||||
json,
|
||||
@ -292,9 +288,7 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Fetching a remote actor's informations through it's AP ID
|
||||
"""
|
||||
# Fetching a remote actor's informations through it's AP ID
|
||||
@spec fetch_and_prepare_actor_from_url(String.t()) :: {:ok, struct()} | {:error, atom()} | any()
|
||||
defp fetch_and_prepare_actor_from_url(url) do
|
||||
Logger.debug("Fetching and preparing actor from url")
|
||||
@ -352,8 +346,8 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
def fetch_public_activities_for_actor(%Actor{} = actor, page \\ 1, limit \\ 10) do
|
||||
case actor.type do
|
||||
:Person ->
|
||||
{:ok, events, total} = Events.get_events_for_actor(actor, page, limit)
|
||||
{:ok, comments, total} = Events.get_comments_for_actor(actor, page, limit)
|
||||
{:ok, events, total_events} = Events.get_events_for_actor(actor, page, limit)
|
||||
{:ok, comments, total_comments} = Events.get_comments_for_actor(actor, page, limit)
|
||||
|
||||
event_activities = Enum.map(events, &event_to_activity/1)
|
||||
|
||||
@ -361,7 +355,7 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
|
||||
activities = event_activities ++ comment_activities
|
||||
|
||||
{activities, total}
|
||||
{activities, total_events + total_comments}
|
||||
|
||||
:Service ->
|
||||
bot = Actors.get_bot_by_actor(actor)
|
||||
@ -389,9 +383,7 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Create an activity from an event
|
||||
"""
|
||||
# Create an activity from an event
|
||||
@spec event_to_activity(%Event{}, boolean()) :: Activity.t()
|
||||
defp event_to_activity(%Event{} = event, local \\ true) do
|
||||
%Activity{
|
||||
@ -402,9 +394,7 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Create an activity from a comment
|
||||
"""
|
||||
# Create an activity from a comment
|
||||
@spec comment_to_activity(%Comment{}, boolean()) :: Activity.t()
|
||||
defp comment_to_activity(%Comment{} = comment, local \\ true) do
|
||||
%Activity{
|
||||
@ -415,7 +405,7 @@ defmodule Mobilizon.Service.ActivityPub do
|
||||
}
|
||||
end
|
||||
|
||||
defp ical_event_to_activity(%ExIcal.Event{} = ical_event, %Actor{} = actor, source) do
|
||||
defp ical_event_to_activity(%ExIcal.Event{} = ical_event, %Actor{} = actor, _source) do
|
||||
# Logger.debug(inspect ical_event)
|
||||
# TODO : refactor me !
|
||||
# TODO : also, there should be a form of cache that allows this to be more efficient
|
||||
|
@ -6,8 +6,7 @@ defmodule Mobilizon.Service.ActivityPub.Transmogrifier do
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Events.{Event, Comment}
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
import Ecto.Query
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
|
||||
require Logger
|
||||
|
||||
@ -89,11 +88,10 @@ defmodule Mobilizon.Service.ActivityPub.Transmogrifier do
|
||||
|
||||
with {:ok, %Actor{} = actor} <- Actors.get_or_fetch_by_url(data["actor"]) do
|
||||
Logger.debug("found actor")
|
||||
object = fix_object(data["object"])
|
||||
|
||||
params = %{
|
||||
to: data["to"],
|
||||
object: object,
|
||||
object: object |> fix_object,
|
||||
actor: actor,
|
||||
local: false,
|
||||
published: data["published"],
|
||||
@ -234,11 +232,9 @@ defmodule Mobilizon.Service.ActivityPub.Transmogrifier do
|
||||
|> set_reply_to_uri
|
||||
end
|
||||
|
||||
@doc
|
||||
"""
|
||||
@doc """
|
||||
internal -> Mastodon
|
||||
"""
|
||||
|
||||
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
|
||||
Logger.debug("Prepare outgoing for a note creation")
|
||||
|
||||
@ -249,43 +245,42 @@ defmodule Mobilizon.Service.ActivityPub.Transmogrifier do
|
||||
data =
|
||||
data
|
||||
|> Map.put("object", object)
|
||||
|> Map.put("@context", "https://www.w3.org/ns/activitystreams")
|
||||
|> Map.merge(Utils.make_json_ld_header())
|
||||
|
||||
Logger.debug("Finished prepare outgoing for a note creation")
|
||||
|
||||
{:ok, data}
|
||||
end
|
||||
|
||||
def prepare_outgoing(%{"type" => type} = data) do
|
||||
def prepare_outgoing(%{"type" => _type} = data) do
|
||||
data =
|
||||
data
|
||||
# |> maybe_fix_object_url
|
||||
|> Map.put("@context", "https://www.w3.org/ns/activitystreams")
|
||||
|> Map.merge(Utils.make_json_ld_header())
|
||||
|
||||
{:ok, data}
|
||||
end
|
||||
|
||||
def prepare_outgoing(%Event{} = event) do
|
||||
event =
|
||||
event
|
||||
|> Map.from_struct()
|
||||
|> Map.drop([:__meta__])
|
||||
|> Map.put(:"@context", "https://www.w3.org/ns/activitystreams")
|
||||
|> prepare_object
|
||||
# def prepare_outgoing(%Event{} = event) do
|
||||
# event =
|
||||
# event
|
||||
# |> Map.from_struct()
|
||||
# |> Map.drop([:__meta__])
|
||||
# |> Map.put(:"@context", "https://www.w3.org/ns/activitystreams")
|
||||
# |> prepare_object
|
||||
|
||||
{:ok, event}
|
||||
end
|
||||
# {:ok, event}
|
||||
# end
|
||||
|
||||
def prepare_outgoing(%Comment{} = comment) do
|
||||
comment =
|
||||
comment
|
||||
|> Map.from_struct()
|
||||
|> Map.drop([:__meta__])
|
||||
|> Map.put(:"@context", "https://www.w3.org/ns/activitystreams")
|
||||
|> prepare_object
|
||||
# def prepare_outgoing(%Comment{} = comment) do
|
||||
# comment =
|
||||
# comment
|
||||
# |> Map.from_struct()
|
||||
# |> Map.drop([:__meta__])
|
||||
# |> Map.put(:"@context", "https://www.w3.org/ns/activitystreams")
|
||||
# |> prepare_object
|
||||
|
||||
{:ok, comment}
|
||||
end
|
||||
# {:ok, comment}
|
||||
# end
|
||||
|
||||
#
|
||||
# def maybe_fix_object_url(data) do
|
||||
|
@ -13,11 +13,8 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Activity
|
||||
alias MobilizonWeb
|
||||
alias MobilizonWeb.Router.Helpers
|
||||
alias MobilizonWeb.Endpoint
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Ecto.{Changeset, UUID}
|
||||
import Ecto.Query
|
||||
require Logger
|
||||
|
||||
def make_context(%Activity{data: %{"context" => context}}), do: context
|
||||
@ -97,7 +94,7 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
||||
"""
|
||||
def lazy_put_activity_defaults(map) do
|
||||
if is_map(map["object"]) do
|
||||
object = lazy_put_object_defaults(map["object"], map)
|
||||
object = lazy_put_object_defaults(map["object"])
|
||||
%{map | "object" => object}
|
||||
else
|
||||
map
|
||||
@ -107,9 +104,8 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
||||
@doc """
|
||||
Adds an id and published date if they aren't there.
|
||||
"""
|
||||
def lazy_put_object_defaults(map, activity \\ %{}) do
|
||||
map
|
||||
|> Map.put_new_lazy("published", &make_date/0)
|
||||
def lazy_put_object_defaults(map) do
|
||||
Map.put_new_lazy(map, "published", &make_date/0)
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -174,7 +170,7 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
||||
data
|
||||
end
|
||||
|
||||
with {:ok, comm} <- Events.create_comment(data) do
|
||||
with {:ok, _comment} <- Events.create_comment(data) do
|
||||
:ok
|
||||
else
|
||||
err ->
|
||||
@ -261,7 +257,7 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
||||
# attachments,
|
||||
inReplyTo \\ nil,
|
||||
# tags,
|
||||
cw \\ nil,
|
||||
_cw \\ nil,
|
||||
cc \\ []
|
||||
) do
|
||||
Logger.debug("Making comment data")
|
||||
@ -270,7 +266,7 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
||||
object = %{
|
||||
"type" => "Note",
|
||||
"to" => to,
|
||||
# "cc" => cc,
|
||||
"cc" => cc,
|
||||
"content" => content_html,
|
||||
# "summary" => cw,
|
||||
# "attachment" => attachments,
|
||||
|
@ -8,7 +8,7 @@ defmodule Mobilizon.Service.HTTPSignatures do
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
import Logger
|
||||
require Logger
|
||||
|
||||
def split_signature(sig) do
|
||||
default = %{"headers" => "date"}
|
||||
|
@ -7,7 +7,6 @@ defmodule Mobilizon.Service.Streamer do
|
||||
|
||||
use GenServer
|
||||
require Logger
|
||||
alias Mobilizon.Accounts.Actor
|
||||
|
||||
def init(args) do
|
||||
{:ok, args}
|
||||
|
@ -7,7 +7,6 @@ defmodule Mobilizon.Service.WebFinger do
|
||||
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Service.XmlBuilder
|
||||
alias Mobilizon.Repo
|
||||
require Jason
|
||||
require Logger
|
||||
|
||||
|
1
mix.exs
1
mix.exs
@ -84,6 +84,7 @@ defmodule Mobilizon.Mixfile do
|
||||
{:arc, "~> 0.11.0"},
|
||||
{:arc_ecto, "~> 0.11.0"},
|
||||
{:email_checker, "~> 0.1.2"},
|
||||
{:plug_cowboy, "~> 1.0"},
|
||||
# Dev and test dependencies
|
||||
{:phoenix_live_reload, "~> 1.0", only: :dev},
|
||||
{:ex_machina, "~> 2.2", only: [:dev, :test]},
|
||||
|
1
mix.lock
1
mix.lock
@ -71,6 +71,7 @@
|
||||
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.1.7", "425fff579085f7eacaf009e71940be07338c8d8b78d16e307c50c7d82a381497", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2 or ~> 1.3 or ~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"},
|
||||
"plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"plug_cowboy": {:hex, :plug_cowboy, "1.0.0", "2e2a7d3409746d335f451218b8bb0858301c3de6d668c3052716c909936eb57a", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
|
||||
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
|
||||
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"},
|
||||
|
Loading…
Reference in New Issue
Block a user