send notification when a new node is created according to users's settings
976044
def node_created_handler(sender, **kwargs):
    
    if kwargs['created']:
        obj = kwargs['instance']
        queryset = exclude_owner_of_node(obj)
        create_notifications.delay(**{
            "users": queryset,
            "notification_model": Notification,
            "notification_type": "node_created",
            "related_object": obj
        })
87191
def NotifyAboutEnd(self):
    """"""
    flow_ref = None
    if self.runner_args.client_id:
      flow_ref = rdf_objects.FlowReference(
          client_id=self.client_id, flow_id=self.urn.Basename())

    num_results = len(self.ResultCollection())
    notification_lib.Notify(
        self.creator, rdf_objects.UserNotification.Type.TYPE_FLOW_RUN_COMPLETED,
        "Flow %s completed with %d %s" %
        (self.__class__.__name__, num_results, num_results == 1 and "result" or
         "results"),
        rdf_objects.ObjectReference(
            reference_type=rdf_objects.ObjectReference.Type.FLOW,
            flow=flow_ref))
1302082
def WriteUserNotification(self, notification):
    """"""
    if notification.username not in self.users:
      raise db.UnknownGRRUserError(notification.username)

    cloned_notification = notification.Copy()
    if not cloned_notification.timestamp:
      cloned_notification.timestamp = rdfvalue.RDFDatetime.Now()

    self.notifications_by_username.setdefault(cloned_notification.username,
                                              []).append(cloned_notification)
156660
def notify_block_new(self, block):
        """"""
        payload = block.SerializeToString()
        self._notify(
            "consensus_notifier_notify_block_new", payload, len(payload))
357196
function notifyHandler(data) {
        const notification = Notification.parse(data);
        return evalBlacklist(notification)
            .then(() => {
                forum.emit('log', `Notification ${notification.id}: ${notification.label} received`);
    
                const ids = {
                    post: notification.postId,
                    topic: notification.topicId,
                    user: notification.userId,
                    pm: -1,
                    chat: -1
                };
                return notification.getText()
                    .then((postData) => forum.Commands.get(ids,
                        postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content)))
                    .then((commands) => {
                        if (commands.commands.length === 0) {
                            debug(`Emitting events: 'notification' and 'notification:${notification.type}'`);
                            forum.emit(`notification:${notification.type}`, notification);
                            forum.emit('notification', notification);
                        }
                        return commands;
                    })
                    .then((commands) => commands.execute());
            }).catch((err) => {
                if (err === 'Ignoring notification') {
                //We do not process the notification, but we can continue with life
                    return Promise.resolve();
                }
                throw err;
            });
    }
1002782
def notification_on_post_create_historical_record(
    instance, history_date, history_user, history_change_reason, **kwargs
):
    
    if (
        site_notifications.loaded
        and instance._meta.label_lower in site_notifications.models
    ):
        opts = dict(
            instance=instance,
            user=instance.user_modified or instance.user_created,
            history_date=history_date,
            history_user=history_user,
            history_change_reason=history_change_reason,
            fail_silently=True,
            **kwargs
        )
        site_notifications.notify(**opts)
269642
def notify(self, new_jobs_count):
        

        if not self.use_notify():
            return

        # Not really useful to send more than 100 notifs (to be configured)
        count = min(new_jobs_count, 100)

        notify_key = redis_key("notify", self)

        context.connections.redis.lpush(notify_key, *([1] * count))
        context.connections.redis.expire(notify_key, max(1, int(context.get_current_config()["max_latency"] * 2)))
238450
def create_notifications(users, notification_model, notification_type, related_object):
    
    # shortcuts for readability
    Notification = notification_model

    # text
    additional = related_object.__dict__ if related_object else ''
    notification_text = TEXTS[notification_type] % additional

    # loop users, notification settings check is done in Notification model
    for user in users:

        n = Notification(
            to_user=user,
            type=notification_type,
            text=notification_text
        )
        # attach related object if present
        if related_object:
            n.related_object = related_object
        # create notification and send according to user settings
        n.save()
165959
def notify(self, level, value, target=None, ntype=None, rule=None):
        """"""
        # Did we see the event before?
        if target in self.state and level == self.state[target]:
            return False

        # Do we see the event first time?
        if target not in self.state and level == 'normal' \
                and not self.reactor.options['send_initial']:
            return False

        self.state[target] = level
        return self.reactor.notify(level, self, value, target=target, ntype=ntype, rule=rule)
69709
function notify() {
    var args = arguments
    handlers.forEach(function(f){ f.apply(null, args) }) }
1015269
def notify(title,
           message,
           api_key=NTFY_API_KEY,
           provider_key=None,
           priority=0,
           url=None,
           retcode=None):
    

    data = {
        'apikey': api_key,
        'application': 'ntfy',
        'event': title,
        'description': message,
    }

    if MIN_PRIORITY <= priority <= MAX_PRIORITY:
        data['priority'] = priority
    else:
        raise ValueError('priority must be an integer from {:d} to {:d}'
                         .format(MIN_PRIORITY, MAX_PRIORITY))

    if url is not None:
        data['url'] = url

    if provider_key is not None:
        data['providerkey'] = provider_key

    resp = requests.post(
        API_URL, data=data, headers={
            'User-Agent': USER_AGENT,
        })

    resp.raise_for_status()
99517
def _notify_subnet_create(resource, event, trigger, **kwargs):
    """"""
    context = kwargs['context']
    subnet = kwargs['subnet']
    l3plugin = bc.get_plugin(L3_ROUTER_NAT)
    for router in l3plugin.get_routers(context):
        if (router['external_gateway_info'] and
                (router['external_gateway_info']['network_id'] ==
                 subnet['network_id'])):
            router_data = {'router': router}
            l3plugin.update_router(context, router['id'], router_data)
926831
public function beforeNodeCreate()
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        /* @var $nodeEvent NodeEvent */
        $nodeEvent = $this->eventEmittingService->generate(self::NODE_ADDED, [], NodeEvent::class);
        $this->currentNodeAddEvents[] = $nodeEvent;
        $this->eventEmittingService->pushContext($nodeEvent);
    }
1310361
public function onCreating()
    {
        // Send out email
        if (Request::has('_send_email')) {
            $this->sendCreateEmail();
        }

        // Make them active
        $this->active = 1;

        // If the current user can't grant permissions, make the new admin
        // have the same role as themselves.  Admins created from the CLI (like as
        // part of a migration) won't be logged in.
        if (($admin = app('decoy.user'))
            && !app('decoy.user')->can('grant', 'admins')) {
            $this->role = $admin->role;

        // Otherwise, give the admin a default role if none was defined
        } elseif (empty($this->role)) {
            $this->role = 'admin';
        }
    }
58191
def trigger(self, username, project, branch, **build_params):
        """"""
        method = 'POST'
        url = ('/project/{username}/{project}/tree/{branch}?'
               'circle-token={token}'.format(
                   username=username, project=project,
                   branch=branch, token=self.client.api_token))

        if build_params is not None:
            json_data = self.client.request(method, url,
                                            build_parameters=build_params)
        else:
            json_data = self.client.request(method, url)
        return json_data
86275
private void notifyCreation(final RepositoryObject object, final Map<String, Object> data) {

		for (final ExternalChangeListener listener : externalChangeListeners) {
			listener.onCreate(object, data);
		}
	}
1011642
public function send_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime) {
        global $USER;
        $userid = core_user::is_real_user($userfrom->id) ? $userfrom->id : $USER->id;
        $uniqueid = $this->get_uniqueid_for_user($userid);
        self::send_assignment_notification($userfrom,
                                           $userto,
                                           $messagetype,
                                           $eventtype,
                                           $updatetime,
                                           $this->get_course_module(),
                                           $this->get_context(),
                                           $this->get_course(),
                                           $this->get_module_name(),
                                           $this->get_instance()->name,
                                           $this->is_blind_marking(),
                                           $uniqueid);
    }