kopia lustrzana https://gitlab.com/marnanel/chapeau
When trilby_api hears about a follow request, and the person being
followed has "auto_follow" turned on, the request is automatically granted. If the follower is remote, they automatically get sent an Accept activity. This fixes a regression. As part of this, bowler_pub.create() now sends the ID of the Follow activity through the signal. Also, trilby_api.receivers now uses sensible renames for the "sender" parameters-- they're really the activities which caused the signal.status-serialisers
rodzic
3a1a5f6db2
commit
9d8f4613d4
|
@ -97,7 +97,10 @@ def on_follow(message):
|
||||||
|
|
||||||
result.save()
|
result.save()
|
||||||
|
|
||||||
trilby_signals.followed.send(sender = result)
|
trilby_signals.followed.send(
|
||||||
|
sender = result,
|
||||||
|
id = fields.get('id'),
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ logger = logging.getLogger(name='kepi')
|
||||||
|
|
||||||
import kepi.trilby_api.signals as kepi_signals
|
import kepi.trilby_api.signals as kepi_signals
|
||||||
import kepi.trilby_api.models as kepi_models
|
import kepi.trilby_api.models as kepi_models
|
||||||
|
import kepi.sombrero_sendpub.delivery as sombrero_delivery
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
|
@ -19,10 +20,12 @@ from django.dispatch import receiver
|
||||||
@receiver(kepi_signals.followed)
|
@receiver(kepi_signals.followed)
|
||||||
def on_follow(sender, **kwargs):
|
def on_follow(sender, **kwargs):
|
||||||
|
|
||||||
|
follow = sender # rename to prevent confusion below
|
||||||
|
|
||||||
notification = kepi_models.Notification(
|
notification = kepi_models.Notification(
|
||||||
notification_type = kepi_models.Notification.FOLLOW,
|
notification_type = kepi_models.Notification.FOLLOW,
|
||||||
for_account = sender.following,
|
for_account = follow.following,
|
||||||
about_account = sender.follower,
|
about_account = follow.follower,
|
||||||
)
|
)
|
||||||
|
|
||||||
notification.save()
|
notification.save()
|
||||||
|
@ -30,14 +33,40 @@ def on_follow(sender, **kwargs):
|
||||||
logger.info(' -- storing a notification: %s',
|
logger.info(' -- storing a notification: %s',
|
||||||
notification)
|
notification)
|
||||||
|
|
||||||
|
if follow.following.auto_follow:
|
||||||
|
logger.info(" -- sending automatic Accept")
|
||||||
|
|
||||||
|
if isinstance(follow.follower, kepi_models.RemotePerson):
|
||||||
|
accept = {
|
||||||
|
'type': 'Accept',
|
||||||
|
'to': [follow.follower.url],
|
||||||
|
'actor': follow.following.url,
|
||||||
|
'object': kwargs.get('id'),
|
||||||
|
}
|
||||||
|
|
||||||
|
sombrero_delivery.deliver(
|
||||||
|
activity = accept,
|
||||||
|
sender = follow.following,
|
||||||
|
target_people = [
|
||||||
|
follow.follower,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
follow.requested = False
|
||||||
|
follow.save()
|
||||||
|
else:
|
||||||
|
logger.info(" -- not sending automatic Accept")
|
||||||
|
|
||||||
@receiver(kepi_signals.liked)
|
@receiver(kepi_signals.liked)
|
||||||
def on_like(sender, **kwargs):
|
def on_like(sender, **kwargs):
|
||||||
|
|
||||||
|
like = sender # rename to prevent confusion below
|
||||||
|
|
||||||
notification = kepi_models.Notification(
|
notification = kepi_models.Notification(
|
||||||
notification_type = kepi_models.Notification.FAVOURITE,
|
notification_type = kepi_models.Notification.FAVOURITE,
|
||||||
for_account = sender.liked.account,
|
for_account = like.liked.account,
|
||||||
about_account = sender.liker,
|
about_account = like.liker,
|
||||||
status = sender.liked,
|
status = like.liked,
|
||||||
)
|
)
|
||||||
|
|
||||||
notification.save()
|
notification.save()
|
||||||
|
|
Ładowanie…
Reference in New Issue