Expose correct relay address in federation
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
3982977121
commit
888d2ef4b8
@ -74,6 +74,7 @@ export const INSTANCE_FRAGMENT = gql`
|
|||||||
fragment InstanceFragment on Instance {
|
fragment InstanceFragment on Instance {
|
||||||
domain
|
domain
|
||||||
hasRelay
|
hasRelay
|
||||||
|
relayAddress
|
||||||
followerStatus
|
followerStatus
|
||||||
followedStatus
|
followedStatus
|
||||||
eventCount
|
eventCount
|
||||||
|
@ -3,6 +3,7 @@ import { InstanceFollowStatus } from "./enums";
|
|||||||
export interface IInstance {
|
export interface IInstance {
|
||||||
domain: string;
|
domain: string;
|
||||||
hasRelay: boolean;
|
hasRelay: boolean;
|
||||||
|
relayAddress: string | null;
|
||||||
followerStatus: InstanceFollowStatus;
|
followerStatus: InstanceFollowStatus;
|
||||||
followedStatus: InstanceFollowStatus;
|
followedStatus: InstanceFollowStatus;
|
||||||
personCount: number;
|
personCount: number;
|
||||||
|
@ -162,7 +162,7 @@ export default class Instance extends Vue {
|
|||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: ACCEPT_RELAY,
|
mutation: ACCEPT_RELAY,
|
||||||
variables: {
|
variables: {
|
||||||
address: `relay@${this.domain}`,
|
address: this.instance.relayAddress,
|
||||||
},
|
},
|
||||||
update(cache: ApolloCache<any>) {
|
update(cache: ApolloCache<any>) {
|
||||||
cache.writeFragment({
|
cache.writeFragment({
|
||||||
@ -194,7 +194,7 @@ export default class Instance extends Vue {
|
|||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: REJECT_RELAY,
|
mutation: REJECT_RELAY,
|
||||||
variables: {
|
variables: {
|
||||||
address: `relay@${this.domain}`,
|
address: this.instance.relayAddress,
|
||||||
},
|
},
|
||||||
update(cache: ApolloCache<any>) {
|
update(cache: ApolloCache<any>) {
|
||||||
cache.writeFragment({
|
cache.writeFragment({
|
||||||
@ -242,7 +242,7 @@ export default class Instance extends Vue {
|
|||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: REMOVE_RELAY,
|
mutation: REMOVE_RELAY,
|
||||||
variables: {
|
variables: {
|
||||||
address: `relay@${this.domain}`,
|
address: this.instance.relayAddress,
|
||||||
},
|
},
|
||||||
update(cache: ApolloCache<any>) {
|
update(cache: ApolloCache<any>) {
|
||||||
cache.writeFragment({
|
cache.writeFragment({
|
||||||
|
@ -468,12 +468,16 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
|||||||
context: %{current_user: %User{role: role}}
|
context: %{current_user: %User{role: role}}
|
||||||
})
|
})
|
||||||
when is_admin(role) do
|
when is_admin(role) do
|
||||||
has_relay = Actors.has_relay?(domain)
|
|
||||||
remote_relay = Actors.get_relay(domain)
|
remote_relay = Actors.get_relay(domain)
|
||||||
local_relay = Relay.get_actor()
|
local_relay = Relay.get_actor()
|
||||||
|
|
||||||
result = %{
|
result = %{
|
||||||
has_relay: has_relay,
|
has_relay: !is_nil(remote_relay),
|
||||||
|
relay_address:
|
||||||
|
if(is_nil(remote_relay),
|
||||||
|
do: nil,
|
||||||
|
else: "#{remote_relay.preferred_username}@#{remote_relay.domain}"
|
||||||
|
),
|
||||||
follower_status: follow_status(remote_relay, local_relay),
|
follower_status: follow_status(remote_relay, local_relay),
|
||||||
followed_status: follow_status(local_relay, remote_relay)
|
followed_status: follow_status(local_relay, remote_relay)
|
||||||
}
|
}
|
||||||
|
@ -216,6 +216,10 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
|||||||
description:
|
description:
|
||||||
"Whether this instance has a relay, meaning that it's a Mobilizon instance that we can follow"
|
"Whether this instance has a relay, meaning that it's a Mobilizon instance that we can follow"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
field(:relay_address, :string,
|
||||||
|
description: "If this instance has a relay, it's federated username"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc """
|
@desc """
|
||||||
|
@ -1297,16 +1297,6 @@ defmodule Mobilizon.Actors do
|
|||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec has_relay?(String.t()) :: boolean()
|
|
||||||
def has_relay?(domain) do
|
|
||||||
Actor
|
|
||||||
|> where(
|
|
||||||
[a],
|
|
||||||
a.preferred_username == "relay" and a.domain == ^domain and a.type == :Application
|
|
||||||
)
|
|
||||||
|> Repo.exists?()
|
|
||||||
end
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Returns a relay actor, either `relay@domain` (Mobilizon) or `domain@domain` (Mastodon)
|
Returns a relay actor, either `relay@domain` (Mobilizon) or `domain@domain` (Mastodon)
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user