Move Activity under Events context
This commit is contained in:
parent
e358dcce77
commit
d3f3553ae7
|
@ -1,7 +0,0 @@
|
|||
defmodule Mobilizon.Activity do
|
||||
@moduledoc """
|
||||
Represents an activity
|
||||
"""
|
||||
|
||||
defstruct [:data, :local, :actor, :recipients, :notifications]
|
||||
end
|
13
lib/mobilizon/events/activity.ex
Normal file
13
lib/mobilizon/events/activity.ex
Normal file
|
@ -0,0 +1,13 @@
|
|||
defmodule Mobilizon.Events.Activity do
|
||||
@moduledoc """
|
||||
Represents an activity.
|
||||
"""
|
||||
|
||||
defstruct [
|
||||
:data,
|
||||
:local,
|
||||
:actor,
|
||||
:recipients,
|
||||
:notifications
|
||||
]
|
||||
end
|
|
@ -587,8 +587,6 @@ defmodule Mobilizon.Events do
|
|||
|
||||
def get_tag(id), do: Repo.get(Tag, id)
|
||||
|
||||
|
||||
|
||||
def get_tag_by_slug(slug) do
|
||||
query =
|
||||
from(
|
||||
|
@ -760,9 +758,6 @@ defmodule Mobilizon.Events do
|
|||
Repo.all(final_query)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
alias Mobilizon.Events.Participant
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -3,17 +3,18 @@ defmodule MobilizonWeb.API.Reports do
|
|||
API for Reports
|
||||
"""
|
||||
|
||||
import MobilizonWeb.API.Utils
|
||||
import Mobilizon.Service.Admin.ActionLogService
|
||||
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Events.Activity
|
||||
alias Mobilizon.Reports, as: ReportsAction
|
||||
alias Mobilizon.Reports.{Report, Note}
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Users
|
||||
alias Mobilizon.Users.User
|
||||
import MobilizonWeb.API.Utils
|
||||
import Mobilizon.Service.Admin.ActionLogService
|
||||
|
||||
@doc """
|
||||
Create a report/flag on an actor, and optionally on an event or on comments.
|
||||
|
|
|
@ -2,12 +2,14 @@ defmodule MobilizonWeb.Resolvers.Comment do
|
|||
@moduledoc """
|
||||
Handles the comment-related GraphQL calls
|
||||
"""
|
||||
require Logger
|
||||
alias Mobilizon.Events.Comment
|
||||
alias Mobilizon.Activity
|
||||
|
||||
alias Mobilizon.Events.{Activity, Comment}
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
alias MobilizonWeb.API.Comments
|
||||
|
||||
require Logger
|
||||
|
||||
def create_comment(_parent, %{text: comment, actor_username: username}, %{
|
||||
context: %{current_user: %User{} = _user}
|
||||
}) do
|
||||
|
|
|
@ -2,12 +2,11 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||
@moduledoc """
|
||||
Handles the event-related GraphQL calls
|
||||
"""
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Addresses
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Events.{Event, Participant}
|
||||
alias Mobilizon.Events.{Activity, Event, Participant}
|
||||
alias Mobilizon.Media.Picture
|
||||
alias Mobilizon.Users.User
|
||||
alias MobilizonWeb.Resolvers.Person
|
||||
|
|
|
@ -4,10 +4,12 @@ defmodule MobilizonWeb.Resolvers.Group do
|
|||
"""
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.{Actor, Member}
|
||||
alias Mobilizon.Events.Activity
|
||||
alias Mobilizon.Users.User
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Activity
|
||||
|
||||
alias MobilizonWeb.Resolvers.Person
|
||||
|
||||
require Logger
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -3,9 +3,9 @@ defmodule MobilizonWeb.ActivityPub.ActorView do
|
|||
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.Activity
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
alias Mobilizon.Activity
|
||||
|
||||
@private_visibility_empty_collection %{elements: [], total: 0}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
defmodule MobilizonWeb.ActivityPub.ObjectView do
|
||||
use MobilizonWeb, :view
|
||||
|
||||
alias Mobilizon.Events.Activity
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
alias Mobilizon.Activity
|
||||
|
||||
def render("activity.json", %{activity: %Activity{local: local, data: data} = activity}) do
|
||||
%{
|
||||
|
|
|
@ -12,10 +12,9 @@ defmodule Mobilizon.Service.ActivityPub do
|
|||
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Events.{Event, Comment, Participant}
|
||||
alias Mobilizon.Events.{Activity, Event, Comment, Participant}
|
||||
alias Mobilizon.Service.ActivityPub.Transmogrifier
|
||||
alias Mobilizon.Service.WebFinger
|
||||
alias Mobilizon.Activity
|
||||
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.{Actor, Follower}
|
||||
|
|
|
@ -8,11 +8,13 @@ defmodule Mobilizon.Service.ActivityPub.Relay do
|
|||
Handles following and unfollowing relays and instances
|
||||
"""
|
||||
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.Activity
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
alias MobilizonWeb.API.Follows
|
||||
|
||||
require Logger
|
||||
|
||||
def get_actor do
|
||||
|
|
|
@ -10,25 +10,26 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
|||
Various utils
|
||||
"""
|
||||
|
||||
alias Mobilizon.Storage.Repo
|
||||
alias Ecto.Changeset
|
||||
|
||||
alias Mobilizon.Addresses
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Events.Comment
|
||||
alias Mobilizon.Media.Picture
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Events.{Activity, Comment, Event}
|
||||
alias Mobilizon.Media.Picture
|
||||
alias Mobilizon.Reports
|
||||
alias Mobilizon.Reports.Report
|
||||
alias Mobilizon.Users
|
||||
alias Mobilizon.Service.ActivityPub.Converters
|
||||
alias Ecto.Changeset
|
||||
require Logger
|
||||
alias Mobilizon.Storage.Repo
|
||||
alias Mobilizon.Users
|
||||
|
||||
alias MobilizonWeb.Router.Helpers, as: Routes
|
||||
alias MobilizonWeb.Endpoint
|
||||
|
||||
require Logger
|
||||
|
||||
@actor_types ["Group", "Person", "Application"]
|
||||
|
||||
# Some implementations send the actor URI as the actor field, others send the entire actor object,
|
||||
|
|
|
@ -7,7 +7,8 @@ defmodule Mobilizon.Service.ActivityPub.Visibility do
|
|||
@moduledoc """
|
||||
Utility functions related to content visibility
|
||||
"""
|
||||
alias Mobilizon.Activity
|
||||
|
||||
alias Mobilizon.Events.Activity
|
||||
|
||||
@public "https://www.w3.org/ns/activitystreams#Public"
|
||||
|
||||
|
|
|
@ -9,10 +9,12 @@ defmodule Mobilizon.Service.Federator do
|
|||
"""
|
||||
|
||||
use GenServer
|
||||
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Events.Activity
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Service.ActivityPub.Transmogrifier
|
||||
|
||||
require Logger
|
||||
|
||||
@max_jobs 20
|
||||
|
|
2
mix.exs
2
mix.exs
|
@ -197,6 +197,7 @@ defmodule Mobilizon.Mixfile do
|
|||
Mobilizon.Addresses,
|
||||
Mobilizon.Addresses.Address,
|
||||
Mobilizon.Events,
|
||||
Mobilizon.Events.Activity,
|
||||
Mobilizon.Events.Event,
|
||||
Mobilizon.Events.Comment,
|
||||
Mobilizon.Events.FeedToken,
|
||||
|
@ -218,7 +219,6 @@ defmodule Mobilizon.Mixfile do
|
|||
Mobilizon.Users.User,
|
||||
Mobilizon.Users.UserRole,
|
||||
Mobilizon.Users.Guards,
|
||||
Mobilizon.Activity,
|
||||
Mobilizon.Storage.Ecto,
|
||||
Mobilizon.Storage.Repo
|
||||
],
|
||||
|
|
|
@ -8,11 +8,10 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
|||
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.Events.{Comment, Event, Participant}
|
||||
alias Mobilizon.Events.{Activity, Comment, Event, Participant}
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
alias Mobilizon.Service.ActivityPub.Transmogrifier
|
||||
|
@ -26,7 +25,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
|||
test "it works for incoming events" do
|
||||
data = File.read!("test/fixtures/mobilizon-post-activity.json") |> Jason.decode!()
|
||||
|
||||
{:ok, %Mobilizon.Activity{data: data, local: false}, %Event{} = event} =
|
||||
{:ok, %Activity{data: data, local: false}, %Event{} = event} =
|
||||
Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["id"] ==
|
||||
|
@ -116,7 +115,7 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
|||
test "it works for incoming notices" do
|
||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
|
||||
|
||||
{:ok, %Mobilizon.Activity{data: data, local: false}, _} =
|
||||
{:ok, %Activity{data: data, local: false}, _} =
|
||||
Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["id"] == "https://framapiaf.org/users/admin/statuses/99512778738411822/activity"
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
defmodule MobilizonWeb.API.ReportTest do
|
||||
use Mobilizon.DataCase
|
||||
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Events.Comment
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias MobilizonWeb.API.Reports
|
||||
alias Mobilizon.Reports.{Report, Note}
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Users.User
|
||||
alias Mobilizon.Users
|
||||
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.{Activity, Comment, Event}
|
||||
alias Mobilizon.Reports.{Report, Note}
|
||||
alias Mobilizon.Users
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
alias MobilizonWeb.API.Reports
|
||||
|
||||
describe "reports" do
|
||||
test "creates a report on a event" do
|
||||
%Actor{id: reporter_id, url: reporter_url} = insert(:actor)
|
||||
|
|
Loading…
Reference in a new issue