forked from mirrors/bookwyrm
Updates for broadcast changes
This commit is contained in:
parent
e76f96eb6c
commit
3e02123a0d
3 changed files with 11 additions and 11 deletions
|
@ -86,9 +86,9 @@ def shared_inbox(request):
|
||||||
|
|
||||||
def get_public_key(key_actor):
|
def get_public_key(key_actor):
|
||||||
try:
|
try:
|
||||||
user = models.User.objects.get(actor=key_actor)
|
user = models.User.objects.get(remote_id=key_actor)
|
||||||
public_key = user.public_key
|
public_key = user.public_key
|
||||||
actor = user.actor
|
actor = user.remote_id
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
key_actor,
|
key_actor,
|
||||||
|
@ -149,7 +149,7 @@ def handle_follow(activity):
|
||||||
# figure out who they want to follow -- not using get_or_create because
|
# figure out who they want to follow -- not using get_or_create because
|
||||||
# we only allow you to follow local users
|
# we only allow you to follow local users
|
||||||
try:
|
try:
|
||||||
to_follow = models.User.objects.get(actor=activity['object'])
|
to_follow = models.User.objects.get(remote_id=activity['object'])
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
return False
|
return False
|
||||||
# figure out who the actor is
|
# figure out who the actor is
|
||||||
|
@ -189,7 +189,7 @@ def handle_unfollow(activity):
|
||||||
obj = activity['object']
|
obj = activity['object']
|
||||||
try:
|
try:
|
||||||
requester = get_or_create_remote_user(obj['actor'])
|
requester = get_or_create_remote_user(obj['actor'])
|
||||||
to_unfollow = models.User.objects.get(actor=obj['object'])
|
to_unfollow = models.User.objects.get(remote_id=obj['object'])
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ def handle_unfollow(activity):
|
||||||
def handle_follow_accept(activity):
|
def handle_follow_accept(activity):
|
||||||
''' hurray, someone remote accepted a follow request '''
|
''' hurray, someone remote accepted a follow request '''
|
||||||
# figure out who they want to follow
|
# figure out who they want to follow
|
||||||
requester = models.User.objects.get(actor=activity['object']['actor'])
|
requester = models.User.objects.get(remote_id=activity['object']['actor'])
|
||||||
# figure out who they are
|
# figure out who they are
|
||||||
accepter = get_or_create_remote_user(activity['actor'])
|
accepter = get_or_create_remote_user(activity['actor'])
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ def handle_follow_accept(activity):
|
||||||
@app.task
|
@app.task
|
||||||
def handle_follow_reject(activity):
|
def handle_follow_reject(activity):
|
||||||
''' someone is rejecting a follow request '''
|
''' someone is rejecting a follow request '''
|
||||||
requester = models.User.objects.get(actor=activity['object']['actor'])
|
requester = models.User.objects.get(remote_id=activity['object']['actor'])
|
||||||
rejecter = get_or_create_remote_user(activity['actor'])
|
rejecter = get_or_create_remote_user(activity['actor'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -22,10 +22,10 @@ class FedireadsModel(models.Model):
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
@receiver(models.signals.post_save, sender=FedireadsModel)
|
@receiver(models.signals.post_save)
|
||||||
def execute_after_save(sender, instance, created, *args, **kwargs):
|
def execute_after_save(sender, instance, created, *args, **kwargs):
|
||||||
''' set the remote_id after save (when the id is available) '''
|
''' set the remote_id after save (when the id is available) '''
|
||||||
if not created:
|
if not created or not hasattr(instance, 'get_remote_id'):
|
||||||
return
|
return
|
||||||
instance.remote_id = instance.get_remote_id()
|
instance.remote_id = instance.get_remote_id()
|
||||||
instance.save()
|
instance.save()
|
||||||
|
|
|
@ -14,7 +14,7 @@ from fedireads.broadcast import make_signature
|
||||||
from fedireads.activitypub import get_follow_request
|
from fedireads.activitypub import get_follow_request
|
||||||
from fedireads.settings import DOMAIN
|
from fedireads.settings import DOMAIN
|
||||||
|
|
||||||
Sender = namedtuple('Sender', ('actor', 'private_key', 'public_key'))
|
Sender = namedtuple('Sender', ('remote_id', 'private_key', 'public_key'))
|
||||||
|
|
||||||
class Signature(TestCase):
|
class Signature(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -67,7 +67,7 @@ class Signature(TestCase):
|
||||||
def test_remote_signer(self):
|
def test_remote_signer(self):
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET,
|
responses.GET,
|
||||||
self.fake_remote.actor,
|
self.fake_remote.remote_id,
|
||||||
json={'publicKey': {
|
json={'publicKey': {
|
||||||
'publicKeyPem': self.fake_remote.public_key
|
'publicKeyPem': self.fake_remote.public_key
|
||||||
}},
|
}},
|
||||||
|
@ -82,7 +82,7 @@ class Signature(TestCase):
|
||||||
def test_nonexistent_signer(self):
|
def test_nonexistent_signer(self):
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET,
|
responses.GET,
|
||||||
self.fake_remote.actor,
|
self.fake_remote.remote_id,
|
||||||
json={'error': 'not found'},
|
json={'error': 'not found'},
|
||||||
status=404)
|
status=404)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue