forked from mirrors/bookwyrm
Updates usage of resolve_remote_id
This commit is contained in:
parent
e2f921b7f5
commit
3f61675a0a
5 changed files with 9 additions and 7 deletions
|
@ -7,7 +7,7 @@ class Connector(AbstractMinimalConnector):
|
|||
''' this is basically just for search '''
|
||||
|
||||
def get_or_create_book(self, remote_id):
|
||||
edition = activitypub.resolve_remote_id(models.Edition, remote_id)
|
||||
edition = activitypub.resolve_remote_id(remote_id, model=models.Edition)
|
||||
work = edition.parent_work
|
||||
work.default_edition = work.get_default_edition()
|
||||
work.save()
|
||||
|
|
|
@ -279,7 +279,8 @@ class ManyToManyField(ActivitypubFieldMixin, models.ManyToManyField):
|
|||
except ValidationError:
|
||||
continue
|
||||
items.append(
|
||||
activitypub.resolve_remote_id(remote_id, model=self.related_model)
|
||||
activitypub.resolve_remote_id(
|
||||
remote_id, model=self.related_model)
|
||||
)
|
||||
return items
|
||||
|
||||
|
@ -316,7 +317,8 @@ class TagField(ManyToManyField):
|
|||
# tags can contain multiple types
|
||||
continue
|
||||
items.append(
|
||||
activitypub.resolve_remote_id(link.href, model=self.related_model)
|
||||
activitypub.resolve_remote_id(
|
||||
link.href, model=self.related_model)
|
||||
)
|
||||
return items
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
related_status=self,
|
||||
)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
def delete(self, *args, **kwargs):#pylint: disable=unused-argument
|
||||
''' "delete" a status '''
|
||||
self.deleted = True
|
||||
self.deleted_date = timezone.now()
|
||||
|
|
|
@ -79,7 +79,7 @@ class BaseActivity(TestCase):
|
|||
def test_resolve_remote_id(self):
|
||||
''' look up or load remote data '''
|
||||
# existing item
|
||||
result = resolve_remote_id(models.User, 'http://example.com/a/b')
|
||||
result = resolve_remote_id('http://example.com/a/b', model=models.User)
|
||||
self.assertEqual(result, self.user)
|
||||
|
||||
# remote item
|
||||
|
@ -91,7 +91,7 @@ class BaseActivity(TestCase):
|
|||
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
result = resolve_remote_id(
|
||||
models.User, 'https://example.com/user/mouse')
|
||||
'https://example.com/user/mouse', model=models.User)
|
||||
self.assertIsInstance(result, models.User)
|
||||
self.assertEqual(result.remote_id, 'https://example.com/user/mouse')
|
||||
self.assertEqual(result.name, 'MOUSE?? MOUSE!!')
|
||||
|
|
|
@ -162,7 +162,7 @@ def handle_remote_webfinger(query):
|
|||
if link.get('rel') == 'self':
|
||||
try:
|
||||
user = activitypub.resolve_remote_id(
|
||||
models.User, link['href']
|
||||
link['href'], model=models.User
|
||||
)
|
||||
except KeyError:
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue