def add_participants(self, request, *participants_ids):
"""
Ensures the current user has the authorization to add the participants.
By default, a user can add a participant if he himself is a participant.
A callback can be added in the settings here.
"""
participants_ids_returned_by_callback = getattr(settings, 'REST_MESSAGING_ADD_PARTICIPANTS_CALLBACK', self._limit_participants)(request, *participants_ids)
participations = []
ids = []
for participant_id in participants_ids_returned_by_callback:
participations.append(Participation(participant_id=participant_id, thread=self))
ids.append(participant_id)
Participation.objects.bulk_create(participations)
post_save.send(Thread, instance=self, created=True, created_and_add_participants=True, request_participant_id=request.rest_messaging_participant.id)
return ids
评论列表
文章目录