'Set the `last_activity_at` for both this user and their team in the
given discussion topic. No-op if the user is not a member of
the team for this discussion.'

@classmethod
def update_last_activity(cls, user, discussion_topic_id):

    try:
        membership = cls.objects.get(user=user, team__discussion_topic_id=discussion_topic_id)
    except ObjectDoesNotExist:
        return
    now = datetime.utcnow().replace(tzinfo=pytz.utc)
    membership.last_activity_at = now
    membership.team.last_activity_at = now
    membership.team.save()
    membership.save()
    emit_team_event('edx.team.activity_updated', membership.team.course_id, {'team_id': membership.team.team_id})
