Merge branch 'develop' into 'fix/mix-task-uploads-moduledoc'
# Conflicts: # lib/mix/tasks/pleroma/uploads.ex
This commit is contained in:
commit
bda25b999b
58 changed files with 241 additions and 286 deletions
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Mix.Tasks.Pleroma.Common do
|
||||
@shortdoc "Common functions to be reused in mix tasks"
|
||||
@doc "Common functions to be reused in mix tasks"
|
||||
def start_pleroma do
|
||||
Mix.Task.run("app.start")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
defmodule Mix.Tasks.Pleroma.Instance do
|
||||
use Mix.Task
|
||||
alias Pleroma.{Repo, User}
|
||||
alias Mix.Tasks.Pleroma.Common
|
||||
|
||||
@shortdoc "Manages Pleroma instance"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ defmodule Mix.Tasks.Pleroma.Relay do
|
|||
def run(["follow", target]) do
|
||||
Common.start_pleroma()
|
||||
|
||||
with {:ok, activity} <- Relay.follow(target) do
|
||||
with {:ok, _activity} <- Relay.follow(target) do
|
||||
# put this task to sleep to allow the genserver to push out the messages
|
||||
:timer.sleep(500)
|
||||
else
|
||||
|
|
@ -33,7 +33,7 @@ defmodule Mix.Tasks.Pleroma.Relay do
|
|||
def run(["unfollow", target]) do
|
||||
Common.start_pleroma()
|
||||
|
||||
with {:ok, activity} <- Relay.unfollow(target) do
|
||||
with {:ok, _activity} <- Relay.unfollow(target) do
|
||||
# put this task to sleep to allow the genserver to push out the messages
|
||||
:timer.sleep(500)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
defmodule Mix.Tasks.Pleroma.Uploads do
|
||||
use Mix.Task
|
||||
import Mix.Ecto
|
||||
alias Pleroma.{Upload, Uploaders.Local, Uploaders.S3}
|
||||
alias Pleroma.{Upload, Uploaders.Local}
|
||||
alias Mix.Tasks.Pleroma.Common
|
||||
require Logger
|
||||
|
||||
@log_every 50
|
||||
|
||||
@shortdoc "Migrates uploads from local to remote storage"
|
||||
@moduledoc """
|
||||
Manages uploads
|
||||
|
||||
## Migrate uploads from local to remote storage
|
||||
mix pleroma.uploads migrate_local TARGET_UPLOADER [OPTIONS...]
|
||||
Options:
|
||||
|
|
@ -16,7 +18,6 @@ defmodule Mix.Tasks.Pleroma.Uploads do
|
|||
|
||||
A list of avalible uploaders can be seen in config.exs
|
||||
"""
|
||||
|
||||
def run(["migrate_local", target_uploader | args]) do
|
||||
delete? = Enum.member?(args, "--delete")
|
||||
Common.start_pleroma()
|
||||
|
|
@ -63,7 +64,7 @@ defmodule Mix.Tasks.Pleroma.Uploads do
|
|||
|
||||
File.exists?(root_path) ->
|
||||
file = Path.basename(id)
|
||||
[hash, ext] = String.split(id, ".")
|
||||
hash = Path.rootname(id)
|
||||
{%Pleroma.Upload{id: hash, name: file, path: file, tempfile: root_path}, root_path}
|
||||
|
||||
true ->
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
- `--admin`/`--no-admin` - whether the user is an admin
|
||||
|
||||
## Generate an invite link.
|
||||
|
||||
|
||||
mix pleroma.user invite
|
||||
|
||||
## Delete the user's account.
|
||||
|
|
@ -32,7 +32,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
mix pleroma.user toggle_activated NICKNAME
|
||||
|
||||
## Unsubscribe local users from user's account and deactivate it
|
||||
|
||||
|
||||
mix pleroma.user unsubscribe NICKNAME
|
||||
|
||||
## Create a password reset link.
|
||||
|
|
@ -235,6 +235,26 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
end
|
||||
end
|
||||
|
||||
def run(["invite"]) do
|
||||
Common.start_pleroma()
|
||||
|
||||
with {:ok, token} <- Pleroma.UserInviteToken.create_token() do
|
||||
Mix.shell().info("Generated user invite token")
|
||||
|
||||
url =
|
||||
Pleroma.Web.Router.Helpers.redirect_url(
|
||||
Pleroma.Web.Endpoint,
|
||||
:registration_page,
|
||||
token.token
|
||||
)
|
||||
|
||||
IO.puts(url)
|
||||
else
|
||||
_ ->
|
||||
Mix.shell().error("Could not create invite token.")
|
||||
end
|
||||
end
|
||||
|
||||
defp set_moderator(user, value) do
|
||||
info_cng = User.Info.admin_api_update(user.info, %{is_moderator: value})
|
||||
|
||||
|
|
@ -270,24 +290,4 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
|
||||
Mix.shell().info("Locked status of #{user.nickname}: #{user.info.locked}")
|
||||
end
|
||||
|
||||
def run(["invite"]) do
|
||||
Common.start_pleroma()
|
||||
|
||||
with {:ok, token} <- Pleroma.UserInviteToken.create_token() do
|
||||
Mix.shell().info("Generated user invite token")
|
||||
|
||||
url =
|
||||
Pleroma.Web.Router.Helpers.redirect_url(
|
||||
Pleroma.Web.Endpoint,
|
||||
:registration_page,
|
||||
token.token
|
||||
)
|
||||
|
||||
IO.puts(url)
|
||||
else
|
||||
_ ->
|
||||
Mix.shell().error("Could not create invite token.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue