'Reply to message'

def update(self, request, *args, **kwargs):

    if (request.data is None):
        return rc.BAD_REQUEST
    pkfield = (kwargs.get(self.model._meta.pk.name) or request.data.get(self.model._meta.pk.name))
    if (not pkfield):
        return rc.BAD_REQUEST
    user = request.user.profile
    try:
        message = self.model.objects.get(pk=pkfield)
    except ObjectDoesNotExist:
        return rc.NOT_FOUND
    if (not user.has_permission(message)):
        return rc.FORBIDDEN
    reply = Message()
    reply.author = user.get_contact()
    if (not reply.author):
        return rc.FORBIDDEN
    reply.reply_to = message
    form = MessageReplyForm(user, message.stream_id, message, request.data, instance=reply)
    if form.is_valid():
        reply = form.save()
        reply.set_user_from_request(request)
        reply.recipients.add(reply.author)
        message.read_by.clear()
        try:
            if (('multicomplete_recipients' in request.POST) and request.POST['multicomplete_recipients']):
                try:
                    conf = ModuleSetting.get_for_module('treeio.messaging', 'default_contact_type')[0]
                    default_contact_type = ContactType.objects.get(pk=long(conf.value))
                except Exception:
                    default_contact_type = None
                emails = request.POST['multicomplete_recipients'].split(',')
                for email in emails:
                    emailstr = unicode(email).strip()
                    if re.match('[a-zA-Z0-9+_\\-\\.]+@[0-9a-zA-Z][.-0-9a-zA-Z]*.[a-zA-Z]+', emailstr):
                        (contact, created) = Contact.get_or_create_by_email(emailstr, contact_type=default_contact_type)
                        reply.recipients.add(contact)
                        if created:
                            contact.set_user_from_request(request)
        except:
            pass
        for recipient in reply.recipients.all():
            message.recipients.add(recipient)
        reply.send_email()
        return reply
    else:
        self.status = 400
        return form.errors
