'Send a notification to the originating user.
Args:
message_type: The type of the message. This allows the UI to format
a link to the original object e.g. "ViewObject" or "HostInformation"
subject: The urn of the AFF4 object of interest in this link.
msg: A free form textual message.'

def Notify(self, message_type, subject, msg):

    user = self.context.creator
    if (self.runner_args.notify_to_user and (user not in aff4_users.GRRUser.SYSTEM_USERS)):
        if self.runner_args.client_id:
            client_fd = aff4.FACTORY.Open(self.runner_args.client_id, mode='rw', token=self.token)
            hostname = (client_fd.Get(client_fd.Schema.HOSTNAME) or '')
            client_msg = ('%s:    %s' % (hostname, msg))
        else:
            client_msg = msg
        fd = aff4.FACTORY.Create(aff4.ROOT_URN.Add('users').Add(user), aff4_users.GRRUser, mode='rw', token=self.token)
        fd.Notify(message_type, subject, client_msg, self.session_id)
        fd.Close()
        notification = rdf_flows.Notification(type=message_type, subject=utils.SmartUnicode(subject), message=utils.SmartUnicode(msg), source=self.session_id, timestamp=rdfvalue.RDFDatetime.Now())
        data_store.DB.Set(self.session_id, self.flow_obj.Schema.NOTIFICATION, notification, replace=False, sync=False, token=self.token)
        self.context.user_notified = True
    notification_event = (self.runner_args.notification_event or self.runner_args.notification_urn)
    if notification_event:
        if (self.context.state == rdf_flows.FlowContext.State.ERROR):
            status = rdf_flows.FlowNotification.Status.ERROR
        else:
            status = rdf_flows.FlowNotification.Status.OK
        event = rdf_flows.FlowNotification(session_id=self.context.session_id, flow_name=self.runner_args.flow_name, client_id=self.runner_args.client_id, status=status)
        self.flow_obj.Publish(notification_event, message=event)
