Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into feature/unrepeats
commit
c5dc7e6e31
@ -1,14 +1,14 @@
|
||||
defmodule Mix.Tasks.RmUser do
|
||||
use Mix.Task
|
||||
import Mix.Ecto
|
||||
alias Pleroma.User
|
||||
alias Pleroma.{User, Repo}
|
||||
|
||||
@shortdoc "Permanently delete a user"
|
||||
def run([nickname]) do
|
||||
ensure_started(Repo, [])
|
||||
Mix.Task.run("app.start")
|
||||
|
||||
with %User{local: true} = user <- User.get_by_nickname(nickname) do
|
||||
user.delete()
|
||||
User.delete(user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,65 @@
|
||||
defmodule Pleroma.Web.TwitterAPI.NotificationView do
|
||||
use Pleroma.Web, :view
|
||||
alias Pleroma.{Notification, User}
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
alias Pleroma.Web.MediaProxy
|
||||
alias Pleroma.Web.TwitterAPI.UserView
|
||||
alias Pleroma.Web.TwitterAPI.ActivityView
|
||||
|
||||
defp get_user(ap_id, opts) do
|
||||
cond do
|
||||
user = opts[:users][ap_id] ->
|
||||
user
|
||||
|
||||
String.ends_with?(ap_id, "/followers") ->
|
||||
nil
|
||||
|
||||
ap_id == "https://www.w3.org/ns/activitystreams#Public" ->
|
||||
nil
|
||||
|
||||
true ->
|
||||
User.get_cached_by_ap_id(ap_id)
|
||||
end
|
||||
end
|
||||
|
||||
def render("notification.json", %{notifications: notifications, for: user}) do
|
||||
render_many(
|
||||
notifications,
|
||||
Pleroma.Web.TwitterAPI.NotificationView,
|
||||
"notification.json",
|
||||
for: user
|
||||
)
|
||||
end
|
||||
|
||||
def render(
|
||||
"notification.json",
|
||||
%{
|
||||
notification: %Notification{
|
||||
id: id,
|
||||
seen: seen,
|
||||
activity: activity,
|
||||
inserted_at: created_at
|
||||
},
|
||||
for: user
|
||||
} = opts
|
||||
) do
|
||||
ntype =
|
||||
case activity.data["type"] do
|
||||
"Create" -> "mention"
|
||||
"Like" -> "like"
|
||||
"Announce" -> "repeat"
|
||||
"Follow" -> "follow"
|
||||
end
|
||||
|
||||
from = get_user(activity.data["actor"], opts)
|
||||
|
||||
%{
|
||||
"id" => id,
|
||||
"ntype" => ntype,
|
||||
"notice" => ActivityView.render("activity.json", %{activity: activity, for: user}),
|
||||
"from_profile" => UserView.render("show.json", %{user: from, for: user}),
|
||||
"is_seen" => if(seen, do: 1, else: 0),
|
||||
"created_at" => created_at |> Utils.format_naive_asctime()
|
||||
}
|
||||
end
|
||||
end
|
@ -1 +1 @@
|
||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Pleroma</title><link rel=stylesheet href=/static/font/css/fontello.css><link rel=stylesheet href=/static/font/css/animation.css><link href=/static/css/app.b96f1ae65bf0fc0f0564dbc7f12febfd.css rel=stylesheet></head><body style="display: none"><div id=app></div><script type=text/javascript src=/static/js/manifest.c0906490430c3def2aa2.js></script><script type=text/javascript src=/static/js/vendor.07fdc75424ae7c00c949.js></script><script type=text/javascript src=/static/js/app.be2883b7ed550f51c41d.js></script></body></html>
|
||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Pleroma</title><link rel=stylesheet href=/static/font/css/fontello.css><link rel=stylesheet href=/static/font/css/animation.css><link href=/static/css/app.6c8da1b0ace79ad8881a0e5e716ec818.css rel=stylesheet></head><body style="display: none"><div id=app></div><script type=text/javascript src=/static/js/manifest.f80ee14f782f05d77e39.js></script><script type=text/javascript src=/static/js/vendor.ef2aee0b2db579c3a86a.js></script><script type=text/javascript src=/static/js/app.64c4246ae54f6439cb69.js></script></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 11 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,2 +0,0 @@
|
||||
!function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var r=window.webpackJsonp;window.webpackJsonp=function(c,o){for(var p,l,s=0,i=[];s<c.length;s++)l=c[s],a[l]&&i.push.apply(i,a[l]),a[l]=0;for(p in o)Object.prototype.hasOwnProperty.call(o,p)&&(e[p]=o[p]);for(r&&r(c,o);i.length;)i.shift().call(null,t);if(o[0])return n[0]=0,t(0)};var n={},a={0:0};t.e=function(e,r){if(0===a[e])return r.call(null,t);if(void 0!==a[e])a[e].push(r);else{a[e]=[r];var n=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.src=t.p+"static/js/"+e+"."+{1:"07fdc75424ae7c00c949",2:"be2883b7ed550f51c41d"}[e]+".js",n.appendChild(c)}},t.m=e,t.c=n,t.p="/"}([]);
|
||||
//# sourceMappingURL=manifest.c0906490430c3def2aa2.js.map
|
@ -0,0 +1,2 @@
|
||||
!function(e){function t(a){if(r[a])return r[a].exports;var n=r[a]={exports:{},id:a,loaded:!1};return e[a].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var a=window.webpackJsonp;window.webpackJsonp=function(c,o){for(var p,l,s=0,i=[];s<c.length;s++)l=c[s],n[l]&&i.push.apply(i,n[l]),n[l]=0;for(p in o)Object.prototype.hasOwnProperty.call(o,p)&&(e[p]=o[p]);for(a&&a(c,o);i.length;)i.shift().call(null,t);if(o[0])return r[0]=0,t(0)};var r={},n={0:0};t.e=function(e,a){if(0===n[e])return a.call(null,t);if(void 0!==n[e])n[e].push(a);else{n[e]=[a];var r=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.src=t.p+"static/js/"+e+"."+{1:"ef2aee0b2db579c3a86a",2:"64c4246ae54f6439cb69"}[e]+".js",r.appendChild(c)}},t.m=e,t.c=r,t.p="/"}([]);
|
||||
//# sourceMappingURL=manifest.f80ee14f782f05d77e39.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,108 @@
|
||||
defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.{User, Notification}
|
||||
alias Pleroma.Web.TwitterAPI.TwitterAPI
|
||||
alias Pleroma.Web.TwitterAPI.NotificationView
|
||||
alias Pleroma.Web.TwitterAPI.UserView
|
||||
alias Pleroma.Web.TwitterAPI.ActivityView
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Builders.UserBuilder
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do
|
||||
user = insert(:user, bio: "<span>Here's some html</span>")
|
||||
[user: user]
|
||||
end
|
||||
|
||||
test "A follow notification" do
|
||||
note_activity = insert(:note_activity)
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
follower = insert(:user)
|
||||
|
||||
{:ok, follower} = User.follow(follower, user)
|
||||
{:ok, activity} = ActivityPub.follow(follower, user)
|
||||
Cachex.set(:user_cache, "user_info:#{user.id}", User.user_info(Repo.get!(User, user.id)))
|
||||
[follow_notif] = Notification.for_user(user)
|
||||
|
||||
represented = %{
|
||||
"created_at" => follow_notif.inserted_at |> Utils.format_naive_asctime(),
|
||||
"from_profile" => UserView.render("show.json", %{user: follower, for: user}),
|
||||
"id" => follow_notif.id,
|
||||
"is_seen" => 0,
|
||||
"notice" => ActivityView.render("activity.json", %{activity: activity, for: user}),
|
||||
"ntype" => "follow"
|
||||
}
|
||||
|
||||
assert represented ==
|
||||
NotificationView.render("notification.json", %{notification: follow_notif, for: user})
|
||||
end
|
||||
|
||||
test "A mention notification" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
TwitterAPI.create_status(other_user, %{"status" => "Päivää, @#{user.nickname}"})
|
||||
|
||||
[notification] = Notification.for_user(user)
|
||||
|
||||
represented = %{
|
||||
"created_at" => notification.inserted_at |> Utils.format_naive_asctime(),
|
||||
"from_profile" => UserView.render("show.json", %{user: other_user, for: user}),
|
||||
"id" => notification.id,
|
||||
"is_seen" => 0,
|
||||
"notice" => ActivityView.render("activity.json", %{activity: activity, for: user}),
|
||||
"ntype" => "mention"
|
||||
}
|
||||
|
||||
assert represented ==
|
||||
NotificationView.render("notification.json", %{notification: notification, for: user})
|
||||
end
|
||||
|
||||
test "A retweet notification" do
|
||||
note_activity = insert(:note_activity)
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
repeater = insert(:user)
|
||||
|
||||
{:ok, activity} = TwitterAPI.repeat(repeater, note_activity.id)
|
||||
[notification] = Notification.for_user(user)
|
||||
|
||||
represented = %{
|
||||
"created_at" => notification.inserted_at |> Utils.format_naive_asctime(),
|
||||
"from_profile" => UserView.render("show.json", %{user: repeater, for: user}),
|
||||
"id" => notification.id,
|
||||
"is_seen" => 0,
|
||||
"notice" =>
|
||||
ActivityView.render("activity.json", %{activity: notification.activity, for: user}),
|
||||
"ntype" => "repeat"
|
||||
}
|
||||
|
||||
assert represented ==
|
||||
NotificationView.render("notification.json", %{notification: notification, for: user})
|
||||
end
|
||||
|
||||
test "A like notification" do
|
||||
note_activity = insert(:note_activity)
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
liker = insert(:user)
|
||||
|
||||
{:ok, activity} = TwitterAPI.fav(liker, note_activity.id)
|
||||
[notification] = Notification.for_user(user)
|
||||
|
||||
represented = %{
|
||||
"created_at" => notification.inserted_at |> Utils.format_naive_asctime(),
|
||||
"from_profile" => UserView.render("show.json", %{user: liker, for: user}),
|
||||
"id" => notification.id,
|
||||
"is_seen" => 0,
|
||||
"notice" =>
|
||||
ActivityView.render("activity.json", %{activity: notification.activity, for: user}),
|
||||
"ntype" => "like"
|
||||
}
|
||||
|
||||
assert represented ==
|
||||
NotificationView.render("notification.json", %{notification: notification, for: user})
|
||||
end
|
||||
end
|
Loading…
Reference in new issue