forked from AkkomaGang/akkoma
Merge branch 'develop' into feature/activitypub
This commit is contained in:
commit
94db9ac4db
6 changed files with 81 additions and 6 deletions
12
README.md
12
README.md
|
@ -59,3 +59,15 @@ Add the following to your `dev.secret.exs` or `prod.secret.exs` if you want to p
|
|||
proxy_url: "127.0.0.1:8123"
|
||||
|
||||
This is useful for running pleroma inside Tor or i2p.
|
||||
|
||||
## Admin Tasks
|
||||
|
||||
### Password reset
|
||||
|
||||
Run `mix generate_password_reset username` to generate a password reset link that you can then send to the user.
|
||||
|
||||
### Moderators
|
||||
|
||||
You can make users moderators. They will then be able to delete any post.
|
||||
|
||||
Run `mix set_moderator username [true|false]` to make user a moderator or not.
|
||||
|
|
19
lib/mix/tasks/generate_password_reset.ex
Normal file
19
lib/mix/tasks/generate_password_reset.ex
Normal file
|
@ -0,0 +1,19 @@
|
|||
defmodule Mix.Tasks.GeneratePasswordReset do
|
||||
use Mix.Task
|
||||
import Mix.Ecto
|
||||
alias Pleroma.{Repo, User}
|
||||
|
||||
@shortdoc "Generate password reset link for user"
|
||||
def run([nickname]) do
|
||||
Mix.Task.run("app.start")
|
||||
|
||||
with %User{local: true} = user <- User.get_by_nickname(nickname),
|
||||
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
|
||||
IO.puts "Generated password reset token for #{user.nickname}"
|
||||
IO.puts "Url: #{Pleroma.Web.Router.Helpers.util_url(Pleroma.Web.Endpoint, :show_password_reset, token.token)}"
|
||||
else
|
||||
_ ->
|
||||
IO.puts "No local user #{nickname}"
|
||||
end
|
||||
end
|
||||
end
|
27
lib/mix/tasks/make_moderator.ex
Normal file
27
lib/mix/tasks/make_moderator.ex
Normal file
|
@ -0,0 +1,27 @@
|
|||
defmodule Mix.Tasks.SetModerator do
|
||||
use Mix.Task
|
||||
import Mix.Ecto
|
||||
alias Pleroma.{Repo, User}
|
||||
|
||||
@shortdoc "Set moderator status"
|
||||
def run([nickname | rest]) do
|
||||
ensure_started(Repo, [])
|
||||
|
||||
moderator = case rest do
|
||||
[moderator] -> moderator == "true"
|
||||
_ -> true
|
||||
end
|
||||
|
||||
with %User{local: true} = user <- User.get_by_nickname(nickname) do
|
||||
info = user.info
|
||||
|> Map.put("is_moderator", !!moderator)
|
||||
cng = User.info_changeset(user, %{info: info})
|
||||
user = Repo.update!(cng)
|
||||
|
||||
IO.puts "Moderator status of #{nickname}: #{user.info["is_moderator"]}"
|
||||
else
|
||||
_ ->
|
||||
IO.puts "No local user #{nickname}"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
def delete(activity_id, user) do
|
||||
with %Activity{data: %{"object" => %{"id" => object_id}}} <- Repo.get(Activity, activity_id),
|
||||
%Object{} = object <- Object.get_by_ap_id(object_id),
|
||||
true <- user.ap_id == object.data["actor"],
|
||||
true <- user.info["is_moderator"] || (user.ap_id == object.data["actor"]),
|
||||
{:ok, delete} <- ActivityPub.delete(object) do
|
||||
{:ok, delete}
|
||||
end
|
||||
|
|
|
@ -41,7 +41,9 @@ def render("user.json", %{user: user = %User{}} = assigns) do
|
|||
"profile_image_url_https" => image,
|
||||
"profile_image_url_profile_size" => image,
|
||||
"profile_image_url_original" => image,
|
||||
"rights" => %{},
|
||||
"rights" => %{
|
||||
"delete_others_notice" => !!user.info["is_moderator"]
|
||||
},
|
||||
"screen_name" => user.nickname,
|
||||
"statuses_count" => user_info[:note_count],
|
||||
"statusnet_profile_url" => user.ap_id,
|
||||
|
|
|
@ -53,7 +53,9 @@ test "A user" do
|
|||
"following" => false,
|
||||
"follows_you" => false,
|
||||
"statusnet_blocking" => false,
|
||||
"rights" => %{},
|
||||
"rights" => %{
|
||||
"delete_others_notice" => false
|
||||
},
|
||||
"statusnet_profile_url" => user.ap_id,
|
||||
"cover_photo" => banner,
|
||||
"background_image" => nil,
|
||||
|
@ -86,7 +88,9 @@ test "A user for a given other follower", %{user: user} do
|
|||
"following" => true,
|
||||
"follows_you" => false,
|
||||
"statusnet_blocking" => false,
|
||||
"rights" => %{},
|
||||
"rights" => %{
|
||||
"delete_others_notice" => false
|
||||
},
|
||||
"statusnet_profile_url" => user.ap_id,
|
||||
"cover_photo" => banner,
|
||||
"background_image" => nil,
|
||||
|
@ -120,7 +124,9 @@ test "A user that follows you", %{user: user} do
|
|||
"following" => false,
|
||||
"follows_you" => true,
|
||||
"statusnet_blocking" => false,
|
||||
"rights" => %{},
|
||||
"rights" => %{
|
||||
"delete_others_notice" => false
|
||||
},
|
||||
"statusnet_profile_url" => follower.ap_id,
|
||||
"cover_photo" => banner,
|
||||
"background_image" => nil,
|
||||
|
@ -130,6 +136,13 @@ test "A user that follows you", %{user: user} do
|
|||
assert represented == UserView.render("show.json", %{user: follower, for: user})
|
||||
end
|
||||
|
||||
test "a user that is a moderator" do
|
||||
user = insert(:user, %{info: %{"is_moderator" => true}})
|
||||
represented = UserView.render("show.json", %{user: user, for: user})
|
||||
|
||||
assert represented["rights"]["delete_others_notice"]
|
||||
end
|
||||
|
||||
test "A blocked user for the blocker" do
|
||||
user = insert(:user)
|
||||
blocker = insert(:user)
|
||||
|
@ -154,7 +167,9 @@ test "A blocked user for the blocker" do
|
|||
"following" => false,
|
||||
"follows_you" => false,
|
||||
"statusnet_blocking" => true,
|
||||
"rights" => %{},
|
||||
"rights" => %{
|
||||
"delete_others_notice" => false
|
||||
},
|
||||
"statusnet_profile_url" => user.ap_id,
|
||||
"cover_photo" => banner,
|
||||
"background_image" => nil,
|
||||
|
|
Loading…
Reference in a new issue