2018-10-11 15:37:39 +00:00
|
|
|
defmodule Mobilizon.Factory do
|
2018-01-14 16:56:50 +00:00
|
|
|
@moduledoc """
|
2019-09-08 22:52:49 +00:00
|
|
|
Factory for fixtures with ExMachina.
|
2018-01-14 16:56:50 +00:00
|
|
|
"""
|
2019-09-08 22:52:49 +00:00
|
|
|
|
2019-09-07 23:49:56 +00:00
|
|
|
use ExMachina.Ecto, repo: Mobilizon.Storage.Repo
|
2019-09-08 22:52:49 +00:00
|
|
|
|
2019-04-25 17:05:05 +00:00
|
|
|
alias Mobilizon.Actors.Actor
|
2019-09-08 22:52:49 +00:00
|
|
|
alias Mobilizon.Crypto
|
|
|
|
|
2020-01-28 18:18:33 +00:00
|
|
|
alias Mobilizon.Web.{Endpoint, Upload}
|
2020-01-26 20:36:50 +00:00
|
|
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
2018-01-13 22:33:03 +00:00
|
|
|
|
|
|
|
def user_factory do
|
2019-03-05 16:23:05 +00:00
|
|
|
%Mobilizon.Users.User{
|
2018-01-13 22:33:03 +00:00
|
|
|
password_hash: "Jane Smith",
|
|
|
|
email: sequence(:email, &"email-#{&1}@example.com"),
|
2019-03-06 17:45:26 +00:00
|
|
|
role: :user,
|
2019-02-14 13:19:55 +00:00
|
|
|
confirmed_at: DateTime.utc_now() |> DateTime.truncate(:second),
|
2019-01-11 13:07:14 +00:00
|
|
|
confirmation_sent_at: nil,
|
2020-06-27 17:12:45 +00:00
|
|
|
confirmation_token: nil,
|
|
|
|
provider: nil
|
2018-01-13 22:33:03 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
def settings_factory do
|
|
|
|
%Mobilizon.Users.Setting{
|
|
|
|
timezone: nil,
|
|
|
|
notification_on_day: false,
|
|
|
|
notification_each_week: false,
|
|
|
|
notification_before_event: false,
|
2020-06-08 10:28:19 +00:00
|
|
|
notification_pending_participation: :one_day,
|
2020-11-06 10:34:32 +00:00
|
|
|
notification_pending_membership: :one_day,
|
2021-06-04 14:32:26 +00:00
|
|
|
group_notifications: :one_day,
|
|
|
|
last_notification_sent: nil,
|
|
|
|
user: build(:user)
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-05-30 16:59:13 +00:00
|
|
|
def actor_factory do
|
2018-06-14 15:25:55 +00:00
|
|
|
preferred_username = sequence("thomas")
|
2018-07-27 08:45:35 +00:00
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Actors.Actor{
|
2018-06-14 15:25:55 +00:00
|
|
|
preferred_username: preferred_username,
|
2018-01-13 22:33:03 +00:00
|
|
|
domain: nil,
|
2018-11-27 16:54:54 +00:00
|
|
|
followers: [],
|
|
|
|
followings: [],
|
2019-09-08 22:52:49 +00:00
|
|
|
keys: Crypto.generate_rsa_2048_private_key(),
|
2018-08-01 12:45:18 +00:00
|
|
|
type: :Person,
|
2019-05-22 12:12:11 +00:00
|
|
|
avatar: build(:file, name: "Avatar"),
|
|
|
|
banner: build(:file, name: "Banner"),
|
2019-04-25 17:05:05 +00:00
|
|
|
url: Actor.build_url(preferred_username, :page),
|
|
|
|
followers_url: Actor.build_url(preferred_username, :followers),
|
|
|
|
following_url: Actor.build_url(preferred_username, :following),
|
2019-07-30 14:40:59 +00:00
|
|
|
inbox_url: Actor.build_url(preferred_username, :inbox),
|
2019-04-25 17:05:05 +00:00
|
|
|
outbox_url: Actor.build_url(preferred_username, :outbox),
|
2020-02-18 07:57:00 +00:00
|
|
|
shared_inbox_url: "#{Endpoint.url()}/inbox",
|
2020-02-14 16:56:36 +00:00
|
|
|
last_refreshed_at: DateTime.utc_now(),
|
2020-09-02 15:42:17 +00:00
|
|
|
user: build(:user),
|
2021-01-20 17:16:44 +00:00
|
|
|
visibility: :public,
|
|
|
|
manually_approves_followers: false
|
2018-01-13 22:33:03 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-08-01 12:45:18 +00:00
|
|
|
def group_factory do
|
2020-02-18 07:57:00 +00:00
|
|
|
preferred_username = sequence("myGroup")
|
|
|
|
|
2018-08-01 12:45:18 +00:00
|
|
|
struct!(
|
|
|
|
actor_factory(),
|
|
|
|
%{
|
2020-02-18 07:57:00 +00:00
|
|
|
preferred_username: preferred_username,
|
|
|
|
type: :Group,
|
|
|
|
url: Actor.build_url(preferred_username, :page),
|
|
|
|
followers_url: Actor.build_url(preferred_username, :followers),
|
|
|
|
following_url: Actor.build_url(preferred_username, :following),
|
|
|
|
members_url: Actor.build_url(preferred_username, :members),
|
|
|
|
resources_url: Actor.build_url(preferred_username, :resources),
|
|
|
|
inbox_url: Actor.build_url(preferred_username, :inbox),
|
|
|
|
outbox_url: Actor.build_url(preferred_username, :outbox),
|
|
|
|
user: nil
|
2018-08-01 12:45:18 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2020-10-14 07:45:58 +00:00
|
|
|
def instance_actor_factory do
|
|
|
|
preferred_username = "relay"
|
|
|
|
domain = "#{sequence("mydomain")}.com"
|
|
|
|
|
|
|
|
struct!(
|
|
|
|
actor_factory(),
|
|
|
|
%{
|
|
|
|
preferred_username: preferred_username,
|
|
|
|
type: :Application,
|
|
|
|
url: "http://#{domain}/#{preferred_username}",
|
|
|
|
followers_url: Actor.build_url(preferred_username, :followers),
|
|
|
|
following_url: Actor.build_url(preferred_username, :following),
|
|
|
|
members_url: Actor.build_url(preferred_username, :members),
|
|
|
|
resources_url: Actor.build_url(preferred_username, :resources),
|
|
|
|
inbox_url: Actor.build_url(preferred_username, :inbox),
|
|
|
|
outbox_url: Actor.build_url(preferred_username, :outbox),
|
|
|
|
user: nil,
|
|
|
|
domain: domain
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-08-01 12:45:18 +00:00
|
|
|
def follower_factory do
|
2019-07-30 14:40:59 +00:00
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Actors.Follower{
|
2018-08-01 12:45:18 +00:00
|
|
|
target_actor: build(:actor),
|
2019-07-30 14:40:59 +00:00
|
|
|
actor: build(:actor),
|
|
|
|
id: uuid,
|
2021-01-20 17:16:44 +00:00
|
|
|
url: "#{Endpoint.url()}/follows/#{uuid}",
|
|
|
|
approved: false
|
2018-08-01 12:45:18 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
def tag_factory do
|
|
|
|
%Mobilizon.Events.Tag{
|
2019-09-04 16:24:31 +00:00
|
|
|
title: sequence("MyTag"),
|
|
|
|
slug: sequence("my-tag")
|
2018-11-23 14:03:53 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-02-14 13:19:55 +00:00
|
|
|
def tag_relation_factory do
|
|
|
|
%Mobilizon.Events.TagRelation{
|
|
|
|
tag: build(:tag),
|
|
|
|
link: build(:tag)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-17 10:39:01 +00:00
|
|
|
def address_factory do
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Addresses.Address{
|
2018-01-17 10:39:01 +00:00
|
|
|
description: sequence("MyAddress"),
|
2019-03-14 17:31:14 +00:00
|
|
|
geom: %Geo.Point{coordinates: {45.75, 4.85}, srid: 4326},
|
2019-07-30 08:35:29 +00:00
|
|
|
url: "http://mobilizon.test/address/#{Ecto.UUID.generate()}",
|
2019-03-22 14:51:23 +00:00
|
|
|
country: "My Country",
|
|
|
|
locality: "My Locality",
|
|
|
|
region: "My Region",
|
|
|
|
postal_code: "My Postal Code",
|
|
|
|
street: "My Street Address"
|
2018-01-17 10:39:01 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-06-14 15:25:55 +00:00
|
|
|
def comment_factory do
|
2018-08-24 09:34:00 +00:00
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
2020-07-09 15:24:28 +00:00
|
|
|
%Mobilizon.Discussions.Comment{
|
2018-06-14 15:25:55 +00:00
|
|
|
text: "My Comment",
|
|
|
|
actor: build(:actor),
|
|
|
|
event: build(:event),
|
2018-08-24 09:34:00 +00:00
|
|
|
uuid: uuid,
|
2019-10-25 15:43:37 +00:00
|
|
|
mentions: [],
|
2020-11-26 10:41:13 +00:00
|
|
|
media: [],
|
2020-07-09 15:24:28 +00:00
|
|
|
attributed_to: nil,
|
|
|
|
local: true,
|
|
|
|
deleted_at: nil,
|
2019-10-25 15:43:37 +00:00
|
|
|
tags: build_list(3, :tag),
|
2018-11-27 16:54:54 +00:00
|
|
|
in_reply_to_comment: nil,
|
2021-06-02 16:37:17 +00:00
|
|
|
is_announcement: false,
|
2020-08-14 09:32:23 +00:00
|
|
|
published_at: DateTime.utc_now(),
|
2019-04-25 17:05:05 +00:00
|
|
|
url: Routes.page_url(Endpoint, :comment, uuid)
|
2018-06-14 15:25:55 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-13 22:33:03 +00:00
|
|
|
def event_factory do
|
2018-05-30 16:59:13 +00:00
|
|
|
actor = build(:actor)
|
2019-04-11 16:25:32 +00:00
|
|
|
start = Timex.shift(DateTime.utc_now(), hours: 2)
|
2019-01-21 14:08:22 +00:00
|
|
|
uuid = Ecto.UUID.generate()
|
2018-05-17 09:32:23 +00:00
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Events.Event{
|
2018-11-06 09:30:27 +00:00
|
|
|
title: sequence("Ceci est un événement"),
|
|
|
|
description: "Ceci est une description avec une première phrase assez longue,
|
|
|
|
puis sur une seconde ligne",
|
2019-01-21 14:08:22 +00:00
|
|
|
begins_on: start,
|
|
|
|
ends_on: Timex.shift(start, hours: 2),
|
2018-05-30 16:59:13 +00:00
|
|
|
organizer_actor: actor,
|
2020-07-09 15:24:28 +00:00
|
|
|
attributed_to: nil,
|
2019-02-22 15:54:01 +00:00
|
|
|
category: sequence("something"),
|
2018-07-04 14:23:52 +00:00
|
|
|
physical_address: build(:address),
|
2019-01-14 14:56:07 +00:00
|
|
|
visibility: :public,
|
2019-04-11 16:25:32 +00:00
|
|
|
tags: build_list(3, :tag),
|
2019-10-25 15:43:37 +00:00
|
|
|
mentions: [],
|
2019-12-20 12:04:34 +00:00
|
|
|
local: true,
|
2019-11-05 16:49:40 +00:00
|
|
|
publish_at: DateTime.utc_now(),
|
2019-04-25 17:05:05 +00:00
|
|
|
url: Routes.page_url(Endpoint, :event, uuid),
|
2020-11-26 10:41:13 +00:00
|
|
|
picture: insert(:media),
|
2019-08-14 15:45:11 +00:00
|
|
|
uuid: uuid,
|
2019-10-11 09:50:06 +00:00
|
|
|
join_options: :free,
|
2019-10-25 15:43:37 +00:00
|
|
|
options: %{},
|
2020-02-18 07:57:00 +00:00
|
|
|
participant_stats: %{},
|
2020-09-29 07:53:48 +00:00
|
|
|
status: :confirmed,
|
2020-11-26 10:41:13 +00:00
|
|
|
contacts: [],
|
|
|
|
media: []
|
2018-01-13 22:33:03 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-08-24 09:34:00 +00:00
|
|
|
def participant_factory do
|
2019-08-14 15:45:11 +00:00
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Events.Participant{
|
2018-08-24 09:34:00 +00:00
|
|
|
event: build(:event),
|
2019-01-21 14:08:22 +00:00
|
|
|
actor: build(:actor),
|
2019-08-14 15:45:11 +00:00
|
|
|
role: :creator,
|
|
|
|
url: "#{Endpoint.url()}/join/event/#{uuid}",
|
2019-12-20 12:04:34 +00:00
|
|
|
id: uuid,
|
|
|
|
metadata: %{
|
|
|
|
email: nil,
|
|
|
|
confirmation_token: nil
|
|
|
|
}
|
2018-08-24 09:34:00 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-13 22:33:03 +00:00
|
|
|
def session_factory do
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Events.Session{
|
2018-07-27 08:45:35 +00:00
|
|
|
title: sequence("MySession"),
|
|
|
|
event: build(:event),
|
|
|
|
track: build(:track)
|
2018-01-13 22:33:03 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def track_factory do
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Events.Track{
|
2018-01-13 22:33:03 +00:00
|
|
|
name: sequence("MyTrack"),
|
|
|
|
event: build(:event)
|
|
|
|
}
|
|
|
|
end
|
2018-01-17 10:39:01 +00:00
|
|
|
|
2018-06-14 15:25:55 +00:00
|
|
|
def bot_factory do
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Actors.Bot{
|
2018-06-14 15:25:55 +00:00
|
|
|
source: "https://mysource.tld/feed.ics",
|
|
|
|
type: "ics",
|
|
|
|
user: build(:user),
|
2018-07-27 08:45:35 +00:00
|
|
|
actor: build(:actor)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def member_factory do
|
2020-02-18 07:57:00 +00:00
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
%Mobilizon.Actors.Member{
|
2018-07-27 08:45:35 +00:00
|
|
|
parent: build(:actor),
|
2019-01-25 08:23:44 +00:00
|
|
|
actor: build(:actor),
|
2020-02-18 07:57:00 +00:00
|
|
|
role: :not_approved,
|
|
|
|
id: uuid,
|
|
|
|
url: "#{Endpoint.url()}/member/#{uuid}"
|
2018-01-17 10:39:01 +00:00
|
|
|
}
|
|
|
|
end
|
2019-03-08 11:25:06 +00:00
|
|
|
|
|
|
|
def feed_token_factory do
|
|
|
|
user = build(:user)
|
|
|
|
|
|
|
|
%Mobilizon.Events.FeedToken{
|
|
|
|
user: user,
|
|
|
|
actor: build(:actor, user: user),
|
|
|
|
token: Ecto.UUID.generate()
|
|
|
|
}
|
|
|
|
end
|
2019-05-22 12:12:11 +00:00
|
|
|
|
|
|
|
def file_factory do
|
2019-06-05 16:29:39 +00:00
|
|
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
|
|
|
|
|
|
|
file = %Plug.Upload{
|
|
|
|
content_type: "image/jpg",
|
|
|
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
|
|
|
filename: "image.jpg"
|
|
|
|
}
|
|
|
|
|
|
|
|
{:ok, data} = Upload.store(file)
|
|
|
|
|
|
|
|
%{
|
2019-10-25 15:43:37 +00:00
|
|
|
content_type: "image/jpeg",
|
|
|
|
name: "image.jpg",
|
|
|
|
url: url,
|
|
|
|
size: 13_227
|
2019-06-05 16:29:39 +00:00
|
|
|
} = data
|
|
|
|
|
2020-11-26 10:41:13 +00:00
|
|
|
%Mobilizon.Medias.File{
|
|
|
|
name: "My Media",
|
2019-06-05 16:29:39 +00:00
|
|
|
url: url,
|
2019-06-03 15:13:47 +00:00
|
|
|
content_type: "image/png",
|
|
|
|
size: 13_120
|
2019-05-22 12:12:11 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-11-26 10:41:13 +00:00
|
|
|
def media_factory do
|
|
|
|
%Mobilizon.Medias.Media{
|
2019-05-31 15:58:03 +00:00
|
|
|
file: build(:file),
|
|
|
|
actor: build(:actor)
|
2019-05-22 12:12:11 +00:00
|
|
|
}
|
|
|
|
end
|
2019-07-23 11:49:22 +00:00
|
|
|
|
|
|
|
def report_factory do
|
|
|
|
%Mobilizon.Reports.Report{
|
|
|
|
content: "This is problematic",
|
|
|
|
status: :open,
|
2019-11-15 17:36:47 +00:00
|
|
|
url: "http://mobilizon.test/report/deae1020-54b8-47df-9eea-d8c0e943e57f/activity",
|
2019-07-23 11:49:22 +00:00
|
|
|
reported: build(:actor),
|
|
|
|
reporter: build(:actor),
|
|
|
|
event: build(:event),
|
|
|
|
comments: build_list(1, :comment)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def report_note_factory do
|
|
|
|
%Mobilizon.Reports.Note{
|
|
|
|
content: "My opinion",
|
|
|
|
moderator: build(:actor),
|
|
|
|
report: build(:report)
|
|
|
|
}
|
|
|
|
end
|
2020-02-18 07:57:00 +00:00
|
|
|
|
|
|
|
def todo_list_factory do
|
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
|
|
|
%Mobilizon.Todos.TodoList{
|
|
|
|
title: sequence("todo list"),
|
|
|
|
actor: build(:group),
|
|
|
|
id: uuid,
|
2020-08-14 09:32:23 +00:00
|
|
|
url: Routes.page_url(Endpoint, :todo_list, uuid),
|
|
|
|
published_at: DateTime.utc_now()
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def todo_factory do
|
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
|
|
|
%Mobilizon.Todos.Todo{
|
|
|
|
id: uuid,
|
|
|
|
title: sequence("my todo"),
|
|
|
|
todo_list: build(:todo_list),
|
|
|
|
status: false,
|
|
|
|
due_date: Timex.shift(DateTime.utc_now(), hours: 2),
|
|
|
|
assigned_to: build(:actor),
|
2020-08-12 14:05:34 +00:00
|
|
|
url: Routes.page_url(Endpoint, :todo, uuid),
|
2020-08-14 09:32:23 +00:00
|
|
|
creator: build(:actor),
|
|
|
|
published_at: DateTime.utc_now()
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def resource_factory do
|
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
title = sequence("my resource")
|
|
|
|
|
|
|
|
%Mobilizon.Resources.Resource{
|
|
|
|
id: uuid,
|
|
|
|
title: title,
|
|
|
|
type: :link,
|
|
|
|
resource_url: "https://somewebsite.com/path",
|
|
|
|
actor: build(:group),
|
|
|
|
creator: build(:actor),
|
|
|
|
parent: nil,
|
2020-08-12 14:05:34 +00:00
|
|
|
url: Routes.page_url(Endpoint, :resource, uuid),
|
2020-08-14 09:32:23 +00:00
|
|
|
published_at: DateTime.utc_now(),
|
2020-02-18 07:57:00 +00:00
|
|
|
path: "/#{title}"
|
|
|
|
}
|
|
|
|
end
|
2020-07-07 13:51:42 +00:00
|
|
|
|
|
|
|
def admin_setting_factory do
|
|
|
|
%Mobilizon.Admin.Setting{
|
|
|
|
group: sequence("group"),
|
|
|
|
name: sequence("name"),
|
|
|
|
value: sequence("value")
|
|
|
|
}
|
|
|
|
end
|
2020-07-09 15:24:28 +00:00
|
|
|
|
|
|
|
def post_factory do
|
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
|
|
|
%Mobilizon.Posts.Post{
|
|
|
|
body: "The <b>HTML</b>body for my Article",
|
|
|
|
title: "My Awesome article",
|
|
|
|
slug: "my-awesome-article-#{ShortUUID.encode!(uuid)}",
|
|
|
|
author: build(:actor),
|
|
|
|
attributed_to: build(:group),
|
|
|
|
id: uuid,
|
|
|
|
draft: false,
|
|
|
|
tags: build_list(3, :tag),
|
|
|
|
visibility: :public,
|
|
|
|
publish_at: DateTime.utc_now(),
|
2020-12-16 10:14:24 +00:00
|
|
|
picture: insert(:media),
|
2020-11-26 10:41:13 +00:00
|
|
|
media: [],
|
2020-07-09 15:24:28 +00:00
|
|
|
url: Routes.page_url(Endpoint, :post, uuid)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def tombstone_factory do
|
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
|
|
|
|
%Mobilizon.Tombstone{
|
|
|
|
uri: "https://mobilizon.test/comments/#{uuid}",
|
|
|
|
actor: build(:actor)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def discussion_factory do
|
|
|
|
uuid = Ecto.UUID.generate()
|
|
|
|
actor = build(:actor)
|
|
|
|
group = build(:group)
|
|
|
|
slug = "my-awesome-discussion-#{ShortUUID.encode!(uuid)}"
|
|
|
|
|
|
|
|
%Mobilizon.Discussions.Discussion{
|
|
|
|
title: "My Awesome discussion",
|
|
|
|
slug: slug,
|
|
|
|
creator: actor,
|
|
|
|
actor: group,
|
|
|
|
id: uuid,
|
2021-03-04 10:43:35 +00:00
|
|
|
last_comment: nil,
|
|
|
|
comments: [],
|
2020-07-09 15:24:28 +00:00
|
|
|
url: Routes.page_url(Endpoint, :discussion, group.preferred_username, slug)
|
|
|
|
}
|
|
|
|
end
|
2021-02-24 18:06:48 +00:00
|
|
|
|
|
|
|
def mobilizon_activity_factory do
|
|
|
|
group = build(:group)
|
|
|
|
actor = build(:actor)
|
|
|
|
event = build(:event, organizer_actor: actor, attributed_to: group)
|
|
|
|
|
|
|
|
%Mobilizon.Activities.Activity{
|
|
|
|
type: :event,
|
|
|
|
subject: :event_created,
|
2021-06-03 15:17:13 +00:00
|
|
|
subject_params: %{
|
|
|
|
"event_title" => event.title,
|
|
|
|
"event_uuid" => event.uuid,
|
|
|
|
"event_id" => event.id
|
|
|
|
},
|
2021-02-24 18:06:48 +00:00
|
|
|
author: actor,
|
|
|
|
group: group,
|
|
|
|
object_type: :event,
|
|
|
|
object_id: to_string(event.id)
|
|
|
|
}
|
|
|
|
end
|
2021-06-03 15:17:13 +00:00
|
|
|
|
|
|
|
def mobilizon_activity_setting_factory do
|
|
|
|
%Mobilizon.Users.ActivitySetting{
|
|
|
|
key: "event_created",
|
|
|
|
method: "email",
|
|
|
|
enabled: true,
|
|
|
|
user: build(:user)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def push_subscription_factory do
|
|
|
|
%Mobilizon.Users.PushSubscription{
|
|
|
|
digest: "",
|
|
|
|
endpoint: "",
|
|
|
|
auth: "",
|
|
|
|
p256dh: "",
|
|
|
|
user: build(:user)
|
|
|
|
}
|
|
|
|
end
|
2018-01-14 16:56:50 +00:00
|
|
|
end
|