mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-20 23:26:42 +00:00
Merge pull request #275 from mouse-reeve/update-book
Fixes updating books from remote instances
This commit is contained in:
commit
64d75fe014
2 changed files with 6 additions and 5 deletions
|
@ -1,13 +1,13 @@
|
||||||
''' functionality outline for a book data connector '''
|
''' functionality outline for a book data connector '''
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from dateutil import parser
|
|
||||||
import pytz
|
import pytz
|
||||||
import requests
|
|
||||||
from requests import HTTPError
|
|
||||||
from urllib3.exceptions import RequestError
|
from urllib3.exceptions import RequestError
|
||||||
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
from dateutil import parser
|
||||||
|
import requests
|
||||||
|
from requests import HTTPError
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,8 @@ def shared_inbox(request):
|
||||||
},
|
},
|
||||||
'Update': {
|
'Update': {
|
||||||
'Person': handle_update_user,
|
'Person': handle_update_user,
|
||||||
'Document': handle_update_book,
|
'Edition': handle_update_book,
|
||||||
|
'Work': handle_update_book,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
activity_type = activity['type']
|
activity_type = activity['type']
|
||||||
|
@ -337,7 +338,7 @@ def handle_update_book(activity):
|
||||||
document = activity['object']
|
document = activity['object']
|
||||||
# check if we have their copy and care about their updates
|
# check if we have their copy and care about their updates
|
||||||
book = models.Book.objects.select_subclasses().filter(
|
book = models.Book.objects.select_subclasses().filter(
|
||||||
remote_id=document['url'],
|
remote_id=document['id'],
|
||||||
sync=True,
|
sync=True,
|
||||||
).first()
|
).first()
|
||||||
if not book:
|
if not book:
|
||||||
|
|
Loading…
Reference in a new issue