mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2025-01-02 21:35:16 +00:00
WIP
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
6ad4e33fab
commit
759b6c06b1
6 changed files with 86 additions and 5 deletions
26
js/src/components/Admin/FollowDetails.vue
Normal file
26
js/src/components/Admin/FollowDetails.vue
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<pre>{{ relayFollow }}</pre>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
import { RELAY_FOLLOW } from "@/graphql/admin";
|
||||||
|
import { IFollower } from "@/types/actor/follower.model";
|
||||||
|
import { Component, Vue } from "vue-property-decorator";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
apollo: {
|
||||||
|
relayFollow: {
|
||||||
|
query: RELAY_FOLLOW,
|
||||||
|
variables() {
|
||||||
|
return {
|
||||||
|
id: this.$route.params.id,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
export default class FollowDetails extends Vue {
|
||||||
|
relayFollow!: IFollower;
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -143,14 +143,14 @@ export default class Followers extends Mixins(RelayMixin) {
|
||||||
|
|
||||||
formatDistanceToNow = formatDistanceToNow;
|
formatDistanceToNow = formatDistanceToNow;
|
||||||
|
|
||||||
async acceptRelays(): Promise<void> {
|
acceptRelays(): void {
|
||||||
await this.checkedRows.forEach((row: IFollower) => {
|
this.checkedRows.forEach((row: IFollower) => {
|
||||||
this.acceptRelay(`${row.actor.preferredUsername}@${row.actor.domain}`);
|
this.acceptRelay(`${row.actor.preferredUsername}@${row.actor.domain}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async rejectRelays(): Promise<void> {
|
rejectRelays(): void {
|
||||||
await this.checkedRows.forEach((row: IFollower) => {
|
this.checkedRows.forEach((row: IFollower) => {
|
||||||
this.rejectRelay(`${row.actor.preferredUsername}@${row.actor.domain}`);
|
this.rejectRelay(`${row.actor.preferredUsername}@${row.actor.domain}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ export const DASHBOARD = gql`
|
||||||
|
|
||||||
export const RELAY_FRAGMENT = gql`
|
export const RELAY_FRAGMENT = gql`
|
||||||
fragment relayFragment on Follower {
|
fragment relayFragment on Follower {
|
||||||
|
id
|
||||||
actor {
|
actor {
|
||||||
id
|
id
|
||||||
preferredUsername
|
preferredUsername
|
||||||
|
@ -83,6 +84,15 @@ export const RELAY_FOLLOWINGS = gql`
|
||||||
${RELAY_FRAGMENT}
|
${RELAY_FRAGMENT}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const RELAY_FOLLOW = gql`
|
||||||
|
query relayFollow($id: ID!) {
|
||||||
|
relayFollow(id: $id) {
|
||||||
|
...relayFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
${RELAY_FRAGMENT}
|
||||||
|
`;
|
||||||
|
|
||||||
export const ADD_RELAY = gql`
|
export const ADD_RELAY = gql`
|
||||||
mutation addRelay($address: String!) {
|
mutation addRelay($address: String!) {
|
||||||
addRelay(address: $address) {
|
addRelay(address: $address) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ export enum SettingsRouteName {
|
||||||
RELAYS = "Relays",
|
RELAYS = "Relays",
|
||||||
RELAY_FOLLOWINGS = "Followings",
|
RELAY_FOLLOWINGS = "Followings",
|
||||||
RELAY_FOLLOWERS = "Followers",
|
RELAY_FOLLOWERS = "Followers",
|
||||||
|
RELAY_FOLLOW = "RELAY_FOLLOW",
|
||||||
USERS = "USERS",
|
USERS = "USERS",
|
||||||
PROFILES = "PROFILES",
|
PROFILES = "PROFILES",
|
||||||
ADMIN_PROFILE = "ADMIN_PROFILE",
|
ADMIN_PROFILE = "ADMIN_PROFILE",
|
||||||
|
@ -186,6 +187,16 @@ export const settingsRoutes: RouteConfig[] = [
|
||||||
],
|
],
|
||||||
props: true,
|
props: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "admin/relays/follow/:id",
|
||||||
|
name: SettingsRouteName.RELAY_FOLLOW,
|
||||||
|
component: (): Promise<EsModuleComponent> =>
|
||||||
|
import(
|
||||||
|
/* webpackChunkName: "RelayFollow" */ "@/components/Admin/FollowDetails.vue"
|
||||||
|
),
|
||||||
|
props: true,
|
||||||
|
meta: { requiredAuth: true },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/moderation",
|
path: "/moderation",
|
||||||
name: SettingsRouteName.MODERATION,
|
name: SettingsRouteName.MODERATION,
|
||||||
|
|
|
@ -6,7 +6,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
||||||
import Mobilizon.Users.Guards
|
import Mobilizon.Users.Guards
|
||||||
|
|
||||||
alias Mobilizon.{Actors, Admin, Config, Events}
|
alias Mobilizon.{Actors, Admin, Config, Events}
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.{Actor, Follower}
|
||||||
alias Mobilizon.Admin.{ActionLog, Setting}
|
alias Mobilizon.Admin.{ActionLog, Setting}
|
||||||
alias Mobilizon.Cldr.Language
|
alias Mobilizon.Cldr.Language
|
||||||
alias Mobilizon.Config
|
alias Mobilizon.Config
|
||||||
|
@ -304,6 +304,35 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
||||||
{:error, :unauthenticated}
|
{:error, :unauthenticated}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Get a relay follow
|
||||||
|
"""
|
||||||
|
def get_relay_follow(
|
||||||
|
_parent,
|
||||||
|
%{id: id},
|
||||||
|
%{context: %{current_user: %User{role: role}}}
|
||||||
|
)
|
||||||
|
when is_admin(role) do
|
||||||
|
%Actor{id: relay_actor_id} = Relay.get_actor()
|
||||||
|
|
||||||
|
case Actors.get_follower(id) do
|
||||||
|
%Follower{target_actor_id: target_actor_id, actor_id: actor_id} = follow
|
||||||
|
when relay_actor_id in [target_actor_id, actor_id] ->
|
||||||
|
{:ok, follow}
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
{:error, :not_found}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_relay_follow(_parent, _args, %{context: %{current_user: %User{}}}) do
|
||||||
|
{:error, :unauthorized}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_relay_follow(_parent, _args, _resolution) do
|
||||||
|
{:error, :unauthenticated}
|
||||||
|
end
|
||||||
|
|
||||||
def create_relay(_parent, %{address: address}, %{context: %{current_user: %User{role: role}}})
|
def create_relay(_parent, %{address: address}, %{context: %{current_user: %User{role: role}}})
|
||||||
when is_admin(role) do
|
when is_admin(role) do
|
||||||
case Relay.follow(address) do
|
case Relay.follow(address) do
|
||||||
|
|
|
@ -215,6 +215,11 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||||
arg(:direction, :string, default_value: :desc, description: "The sorting direction")
|
arg(:direction, :string, default_value: :desc, description: "The sorting direction")
|
||||||
resolve(&Admin.list_relay_followings/3)
|
resolve(&Admin.list_relay_followings/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
field :relay_follow, type: :follower do
|
||||||
|
arg(:id, non_null(:id), description: "The follow ID")
|
||||||
|
resolve(&Admin.get_relay_follow/3)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
object :admin_mutations do
|
object :admin_mutations do
|
||||||
|
|
Loading…
Reference in a new issue