minor style fixes
This commit is contained in:
parent
d1d339225c
commit
8cf7e4405d
|
@ -44,10 +44,9 @@ class ActivityObject:
|
||||||
type: str
|
type: str
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
''' this lets you pass in an object with fields
|
''' this lets you pass in an object with fields that aren't in the
|
||||||
that aren't in the dataclass, which it ignores.
|
dataclass, which it ignores. Any field in the dataclass is required or
|
||||||
Any field in the dataclass is required or has a
|
has a default value '''
|
||||||
default value '''
|
|
||||||
for field in fields(self):
|
for field in fields(self):
|
||||||
try:
|
try:
|
||||||
value = kwargs[field.name]
|
value = kwargs[field.name]
|
||||||
|
@ -59,7 +58,7 @@ class ActivityObject:
|
||||||
|
|
||||||
|
|
||||||
def to_model(self, model, instance=None):
|
def to_model(self, model, instance=None):
|
||||||
''' convert from an activity to a model '''
|
''' convert from an activity to a model instance '''
|
||||||
if not isinstance(self, model.activity_serializer):
|
if not isinstance(self, model.activity_serializer):
|
||||||
raise TypeError('Wrong activity type for model')
|
raise TypeError('Wrong activity type for model')
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ class Work(Book):
|
||||||
type: str = 'Work'
|
type: str = 'Work'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Author(ActivityObject):
|
class Author(ActivityObject):
|
||||||
''' author of a book '''
|
''' author of a book '''
|
||||||
|
|
|
@ -6,6 +6,7 @@ from .base_activity import ActivityObject, Image
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Tombstone(ActivityObject):
|
class Tombstone(ActivityObject):
|
||||||
|
''' the placeholder for a deleted status '''
|
||||||
url: str
|
url: str
|
||||||
published: str
|
published: str
|
||||||
deleted: str
|
deleted: str
|
||||||
|
@ -23,7 +24,6 @@ class Note(ActivityObject):
|
||||||
cc: List[str]
|
cc: List[str]
|
||||||
content: str
|
content: str
|
||||||
replies: Dict
|
replies: Dict
|
||||||
# TODO: this is wrong???
|
|
||||||
attachment: List[Image] = field(default=lambda: [])
|
attachment: List[Image] = field(default=lambda: [])
|
||||||
sensitive: bool = False
|
sensitive: bool = False
|
||||||
type: str = 'Note'
|
type: str = 'Note'
|
||||||
|
|
|
@ -13,7 +13,6 @@ def get_public_recipients(user, software=None):
|
||||||
''' everybody and their public inboxes '''
|
''' everybody and their public inboxes '''
|
||||||
followers = user.followers.filter(local=False)
|
followers = user.followers.filter(local=False)
|
||||||
if software:
|
if software:
|
||||||
# TODO: eventually we may want to handle particular software differently
|
|
||||||
followers = followers.filter(bookwyrm_user=(software == 'bookwyrm'))
|
followers = followers.filter(bookwyrm_user=(software == 'bookwyrm'))
|
||||||
|
|
||||||
# we want shared inboxes when available
|
# we want shared inboxes when available
|
||||||
|
@ -36,7 +35,6 @@ def broadcast(sender, activity, software=None, \
|
||||||
# start with parsing the direct recipients
|
# start with parsing the direct recipients
|
||||||
recipients = [u.inbox for u in direct_recipients or []]
|
recipients = [u.inbox for u in direct_recipients or []]
|
||||||
# and then add any other recipients
|
# and then add any other recipients
|
||||||
# TODO: other kinds of privacy
|
|
||||||
if privacy == 'public':
|
if privacy == 'public':
|
||||||
recipients += get_public_recipients(sender, software=software)
|
recipients += get_public_recipients(sender, software=software)
|
||||||
broadcast_task.delay(
|
broadcast_task.delay(
|
||||||
|
@ -55,7 +53,6 @@ def broadcast_task(sender_id, activity, recipients):
|
||||||
try:
|
try:
|
||||||
sign_and_send(sender, activity, recipient)
|
sign_and_send(sender, activity, recipient)
|
||||||
except requests.exceptions.HTTPError as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
# TODO: maybe keep track of users who cause errors
|
|
||||||
errors.append({
|
errors.append({
|
||||||
'error': str(e),
|
'error': str(e),
|
||||||
'recipient': recipient,
|
'recipient': recipient,
|
||||||
|
|
|
@ -6,7 +6,6 @@ from bookwyrm.tasks import app
|
||||||
|
|
||||||
def password_reset_email(reset_code):
|
def password_reset_email(reset_code):
|
||||||
''' generate a password reset email '''
|
''' generate a password reset email '''
|
||||||
# TODO; this should be tempalted
|
|
||||||
site = models.SiteSettings.get()
|
site = models.SiteSettings.get()
|
||||||
send_email.delay(
|
send_email.delay(
|
||||||
reset_code.user.email,
|
reset_code.user.email,
|
||||||
|
|
|
@ -11,7 +11,14 @@ localname_regex = r'(?P<username>[\w\-_]+)'
|
||||||
user_path = r'^user/%s' % username_regex
|
user_path = r'^user/%s' % username_regex
|
||||||
local_user_path = r'^user/%s' % localname_regex
|
local_user_path = r'^user/%s' % localname_regex
|
||||||
|
|
||||||
status_types = ['status', 'review', 'comment', 'quotation', 'boost', 'generatedstatus']
|
status_types = [
|
||||||
|
'status',
|
||||||
|
'review',
|
||||||
|
'comment',
|
||||||
|
'quotation',
|
||||||
|
'boost',
|
||||||
|
'generatedstatus'
|
||||||
|
]
|
||||||
status_path = r'%s/(%s)/(?P<status_id>\d+)' % \
|
status_path = r'%s/(%s)/(?P<status_id>\d+)' % \
|
||||||
(local_user_path, '|'.join(status_types))
|
(local_user_path, '|'.join(status_types))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue