-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb2eaa5
commit 9f1dc90
Showing
7 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{% extends "admin/base_main.html" %} | ||
{% load activity_tags %} | ||
|
||
{% block subtitle %}Relay{% endblock %} | ||
|
||
{% block settings_content %} | ||
<form action="?subscribe" method="post" class="search"> | ||
<input type="url" name="actor_uri" value="" placeholder="relay actor URI, e.g. https://relay.server/actor"> | ||
{% csrf_token %} | ||
<button>Subscribe</button> | ||
</form> | ||
<table class="items"> | ||
{% for identity in page_obj %} | ||
<tr> | ||
<td class="icon"> | ||
|
||
</td> | ||
<td class="name"> | ||
{{ identity.actor_uri }} | ||
<small>{{ identity.domain.nodeinfo.metadata.nodeName }}</small> | ||
{% if identity.domain.nodeinfo.software %} | ||
<small>{{ identity.domain.nodeinfo.software.name }} / {{ identity.domain.nodeinfo.software.version }}</small> | ||
{% endif %} | ||
</td> | ||
<td> | ||
{% if identity.restriction == 1 %} | ||
<span class="bad">Limited</span> | ||
{% elif identity.restriction == 2 %} | ||
<span class="bad">Blocked</span> | ||
{% endif %} | ||
</td> | ||
<td class="stat"> | ||
{% if identity.follow_state == 'accepting' or identity.follow_state == 'accepted' %} | ||
ACTIVE | ||
{% elif identity.follow_state == 'unrequested' or identity.follow_state == 'pending_approval' %} | ||
ACTIVATING | ||
{% else %} | ||
DEACTIVATING | ||
{% endif %} | ||
<small>({{ identity.follow_state }})</small> | ||
</td> | ||
<td class="actions"> | ||
<form action="?unsubscribe" method="post"> | ||
<input type="hidden" name="actor_uri" value="{{ identity.actor_uri }}"> | ||
{% csrf_token %} | ||
<button>Unsubscribe</button> | ||
</form> | ||
</td> | ||
<td class="actions"> | ||
<form action="?remove" method="post"> | ||
<input type="hidden" name="actor_uri" value="{{ identity.actor_uri }}"> | ||
{% csrf_token %} | ||
<button onclick="return confirm('Sure to force remove?')" {%if identity.follow_state == 'accepting' or identity.follow_state == 'accepted'%}disabled{%endif%}>Remove</button> | ||
</form> | ||
</td> | ||
</tr> | ||
{% empty %} | ||
<tr class="empty"> | ||
<td> | ||
There are no relay yet. | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
<div class="view-options"> | ||
<small><i class="fa-regular fa-lightbulb"></i> invalid actor uri will not show in this list; (un)subscribing may take a while; use remove only when it's stuck in (DE)ACTIVATING state for a long time.</small> | ||
</div> | ||
{% include "admin/_pagination.html" with nouns="relay,relays" %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from django.db import models | ||
from django.shortcuts import redirect | ||
from django.utils.decorators import method_decorator | ||
from django.views.generic import ListView | ||
|
||
from users.decorators import admin_required | ||
from users.models import Identity, RelayActor | ||
|
||
|
||
@method_decorator(admin_required, name="dispatch") | ||
class RelayRoot(ListView): | ||
template_name = "admin/relays.html" | ||
paginate_by = 30 | ||
|
||
def get(self, request, *args, **kwargs): | ||
self.extra_context = { | ||
"section": "relays", | ||
} | ||
return super().get(request, *args, **kwargs) | ||
|
||
def get_queryset(self): | ||
identities = ( | ||
Identity.objects.filter(inbound_follows__source=RelayActor.get_identity()) | ||
.annotate(follow_state=models.F("inbound_follows__state")) | ||
.order_by("-created") | ||
) | ||
return identities | ||
|
||
def post(self, request, *args, **kwargs): | ||
actor_uri = request.POST.get("actor_uri") | ||
if "subscribe" in request.GET: | ||
RelayActor.subscribe(actor_uri) | ||
elif "unsubscribe" in request.GET: | ||
RelayActor.unsubscribe(actor_uri) | ||
elif "remove" in request.GET: | ||
RelayActor.remove(actor_uri) | ||
return redirect(".") |