-
Notifications
You must be signed in to change notification settings - Fork 0
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
707e59b
commit d741347
Showing
10 changed files
with
116 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
from django.db import models | ||
|
||
|
||
class ActorField(models.URLField): | ||
class FedIDField(models.URLField): | ||
""" | ||
A Field that represents a FedID. | ||
.. seealso:: | ||
Activity Pub <Object Identifiers https://www.w3.org/TR/activitypub/#obj-id>_` | ||
**id**: | ||
The object's unique global identifier (unless the object is transient, in which case the id MAY be omitted). | ||
""" | ||
def __init__(self, *args, **kwargs): | ||
super(ActorField, self).__init__(*args, **kwargs) |
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,20 @@ | ||
# Generated by Django 5.0.7 on 2024-08-09 08:46 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("webapp", "0041_alter_actor_id"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="actor", | ||
name="flw", | ||
field=models.ManyToManyField( | ||
blank=True, related_name="flwng", to="webapp.actor" | ||
), | ||
), | ||
] |
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 |
---|---|---|
@@ -1,6 +1,22 @@ | ||
from django.urls import path | ||
from webapp.views.web import FollowingListView | ||
from webapp.views.web import ( | ||
LikeListView, | ||
LikeCreateView, | ||
LikeDetailView, | ||
LikeDeleteView, | ||
) | ||
from webapp.views.signature import SignatureView | ||
|
||
urlpatterns = [ | ||
path(r'', FollowingListView.as_view(), name='following_list'), | ||
path(r"like/", LikeCreateView.as_view(), name="like-create"), | ||
path(r"like/list", LikeListView.as_view(), name="like-list"), | ||
path(r"like/<uuid:pk>", LikeDetailView.as_view(), name="like-detail"), | ||
path( | ||
r"like/<uuid:pk>/delete", LikeDeleteView.as_view(), name="like-delete" | ||
), # noqa: E501 | ||
] | ||
|
||
urlpatterns += [ | ||
# Debug view to show the signature of a given object | ||
path(r"signature", SignatureView.as_view(), name="signature"), | ||
] |
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 |
---|---|---|
@@ -1,3 +1,20 @@ | ||
from .nodeinfo import NodeInfoView, VersionView | ||
from .webfinger import WebFingerView | ||
from .actor import ActorView | ||
from .inbox import InboxView | ||
from .outbox import OutboxView | ||
from .followers import FollowersView | ||
from .following import FollowingView | ||
from .liked import LikedView | ||
|
||
__all__ = ["NodeInfoView", "VersionView"] | ||
__all__ = [ | ||
"NodeInfoView", | ||
"VersionView", | ||
"WebFingerView", | ||
"ActorView", | ||
"InboxView", | ||
"OutboxView", | ||
"FollowersView", | ||
"FollowingView", | ||
"LikedView" | ||
] |
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,32 @@ | ||
from django.views.generic.detail import DetailView | ||
from django.http import JsonResponse | ||
from webapp.models import Profile | ||
|
||
|
||
class LikedView(DetailView): | ||
""" | ||
View for handling the liked a | ||
``` | ||
GET /liked/ | ||
``` | ||
Every actor MAY have a liked collection. This is a list of every object from all of the actor's Like activities, added as a side effect. The liked collection MUST be either an OrderedCollection or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when no authentication is given. | ||
.. seealso:: | ||
`ActivityPub Liked <https://www.w3.org/TR/activitypub/#liked>`_ | ||
.. seealso:: :class:`django.views.generic.View` | ||
.. seealso:: | ||
:class:`django.http.HttpResponse` | ||
""" | ||
|
||
models = Profile | ||
|
||
def liked(self): | ||
return self.get_object().actor.liked.all() | ||
|
||
def get(self, request, *args, **kwargs): | ||
result = {"type": "Collection", "totalItems": 0, "items": []} | ||
return JsonResponse(result, contenttype="application/activity+json") |
File renamed without changes.
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
from django import forms | ||
from django.views.generic import DetailView, ListView | ||
from django.views.generic.edit import CreateView, DeleteView | ||
from webapp.models import Profile as Fllwng | ||
# from webapp.models import Profile as Fllwng | ||
from webapp.models import Actor | ||
|
||
class FollowForm(forms.ModelForm): | ||
class Meta: | ||
model = Actor | ||
fields = ["self", "following"] | ||
fields = "__all__" | ||
widgets = { | ||
"object": forms.URLInput(attrs={"class": "form-control"}), | ||
} | ||
|
||
class FollowingCreateView(CreateView): | ||
model = Fllwng | ||
model = Actor | ||
form_class = FollowForm | ||
|
||
class FollowingDetailView(DetailView): | ||
model = Fllwng | ||
model = Actor | ||
|
||
class FollowingListView(ListView): | ||
model = Fllwng | ||
model = Actor | ||
|
||
class FollowingDeleteView(DeleteView): | ||
model = Fllwng | ||
model = Actor | ||
success_url = "/following/" |