Marks all notification as read

@throws HttpException Throws an exception if the notification is not
found, or if it don't belongs to the logged in user
438153
public function actionReadAll()
    {
        $notificationsIds = Yii::$app->request->post('ids', []);

        foreach ($notificationsIds as $id) {
            $notification = $this->getNotification($id);

            $notification->seen = 1;
            $notification->save();
        }

        return true;
    }
580678
public void readHeader(HttpInputStream in)
        throws IOException
    {
        _state=__MSG_BAD;
        log.warn(LogSupport.NOT_IMPLEMENTED);
    }
1170043
private function getNotification($id)
    {
        /** @var Notification $notification */
        $class = $this->notificationClass;
        $notification = $class::findOne($id);
        if (!$notification) {
            throw new HttpException(404, "Unknown notification");
        }

        if ($notification->user_id != $this->user_id) {
            throw new HttpException(500, "Not your notification");
        }

        return $notification;
    }
206942
public function actionRead($id)
    {
        $notification = $this->getNotification($id);

        $notification->seen = 1;
        $notification->save();

        return $notification;
    }
317110
public synchronized void postNotification(final String name, final Map<String, Object> userInfo) {
		ApptentiveLog.v(NOTIFICATIONS, "Post notification: name=%s userInfo={%s}", name, StringUtils.toString(userInfo));

		final ApptentiveNotificationObserverList list = findObserverList(name);
		if (list != null) {
			list.notifyObservers(new ApptentiveNotification(name, userInfo));
		}
	}
1161031
def notifications_view(request):
    
    page_name = "Your Notifications"
    # Copy the notifications so that they are still unread when we render the page
    notifications = list(request.user.notifications.all())
    request.user.notifications.mark_all_as_read()
    return render_to_response("list_notifications.html", {
        "page_name": page_name,
        "notifications": notifications,
        }, context_instance=RequestContext(request))
429251
def show
      notification = Notification.find_by(id: params[:id])
      activity     = notification.activity

      notification.mark_as_read if notification.unread?

      redirect_to activity_activities_path(activity_id: activity.id)
    end
913666
public function onRead()
    {
        if (false === ($pct = $this->readExact($this->lowMark))) {
            return; // not readed yet
        }
        if ($pct === "<policy-file-request/>\x00") {
            if ($this->pool->policyData) {
                $this->write($p = $this->pool->policyData . "\x00");
            } else {
                $this->write("<error/>\x00");
            }
        }
        $this->finish();
    }
1288389
protected function execute(): void
    {
        /*
        $notification_class = static::NOTIFICATION;
        $notification = new $notification_class($this);
        if(!$notification instanceof Framework\Notification) {
            throw new Framework\Exceptions\NotificationNotFoundException(get_class($this));
        }*/
        if(isset($this->notification))
            $this->tail()->node()->notifySubscribers($this->notification);
    }
1192105
void notifyObservers(ApptentiveNotification notification) {
		boolean hasLostReferences = false;

		// create a temporary list of observers to avoid concurrent modification errors
		List<ApptentiveNotificationObserver> temp = new ArrayList<>(observers.size());
		for (int i = 0; i < observers.size(); ++i) {
			ApptentiveNotificationObserver observer = observers.get(i);
			ObserverWeakReference observerRef = ObjectUtils.as(observer, ObserverWeakReference.class);
			if (observerRef == null || !observerRef.isReferenceLost()) {
				temp.add(observer);
			} else {
				hasLostReferences = true;
			}
		}

		// notify observers
		for (int i = 0; i < temp.size(); ++i) {
			try {
				temp.get(i).onReceiveNotification(notification);
			} catch (Exception e) {
				ApptentiveLog.e(e, "Exception while posting notification: %s", notification);
				logException(e); // TODO: add more context info
			}
		}

		// clean lost references
		if (hasLostReferences) {
			for (int i = observers.size() - 1; i >= 0; --i) {
				final ObserverWeakReference observerRef = ObjectUtils.as(observers.get(i), ObserverWeakReference.class);
				if (observerRef != null && observerRef.isReferenceLost()) {
					observers.remove(i);
				}
			}
		}
	}
318234
public synchronized void handleNotification(Notification notification, Object handback) {
        String type = notification.getType();
        if (REGISTRATION_NOTIFICATION.equals(type)) {
            jolokiaMBeanServer = lookupJolokiaMBeanServer();
            // We need to add the listener provided during construction time to add the Jolokia MBeanServer
            // so that it is kept updated, too.
            if (jolokiaMBeanServerListener != null) {
                JmxUtil.addMBeanRegistrationListener(jolokiaMBeanServer, jolokiaMBeanServerListener, null);
            }
        } else if (UNREGISTRATION_NOTIFICATION.equals(type)) {
            jolokiaMBeanServer = null;
        }

        allMBeanServers.clear();
        if (jolokiaMBeanServer != null) {
            allMBeanServers.add(jolokiaMBeanServer);
        }
        allMBeanServers.addAll(detectedMBeanServers);
    }
282194
@Override
	public void onReceiveNotification(ApptentiveNotification notification) {
		checkConversationQueue();

		if (notification.hasName(NOTIFICATION_ACTIVITY_STARTED) ||
			notification.hasName(NOTIFICATION_ACTIVITY_RESUMED)) {
			final Activity activity = notification.getRequiredUserInfo(NOTIFICATION_KEY_ACTIVITY, Activity.class);
			setCurrentForegroundActivity(activity);
		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_FOREGROUND)) {
			appWentToForeground();
		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_BACKGROUND)) {
			setCurrentForegroundActivity(null);
			appWentToBackground();
		} else if (notification.hasName(NOTIFICATION_PAYLOAD_WILL_START_SEND)) {
			final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class);
			if (payload.getType().equals(PayloadType.message)) {
				resumeSending();
			}
		} else if (notification.hasName(NOTIFICATION_PAYLOAD_DID_FINISH_SEND)) {
			final boolean successful = notification.getRequiredUserInfo(NOTIFICATION_KEY_SUCCESSFUL, Boolean.class);
			final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class);
			final Integer responseCode = notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_CODE, Integer.class);
			final JSONObject responseData = successful ? notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_DATA, JSONObject.class) : null;
			if (responseCode == -1) {
				pauseSending(SEND_PAUSE_REASON_NETWORK);
			}

			if (payload.getType().equals(PayloadType.message)) {
				onSentMessage(payload.getNonce(), responseCode, responseData);
			}
		}
	}
1318587
def get_all(self, request, notifications, mark_as_read=False):
        
        return self.list(request, notifications)
1269582
public function notify() {
        foreach($this->watchers as $watcher) {
          if ($this->stopNotify === true) {
              break;
          }

          $watcher->update($this);
        }
    }
139213
private void onBytesRead(int bytesRead) {
        unnotifiedByteCount += bytesRead;
        if (unnotifiedByteCount >= notifyThresHold) {
            onNotifyBytesRead();
            notifiedByteCount += unnotifiedByteCount;
            unnotifiedByteCount = 0;
        }
    }
626842
def mark_thread_as_read(self, request, pk=None):
        
        # we get the thread and check for permission
        thread = Thread.objects.get(id=pk)
        self.check_object_permissions(request, thread)
        # we save the date
        try:
            participation = Participation.objects.get(thread=thread, participant=request.rest_messaging_participant)
            participation.date_last_check = now()
            participation.save()
            # we return the thread
            serializer = self.get_serializer(thread)
            return Response(serializer.data)
        except Exception:
            return Response(status=status.HTTP_400_BAD_REQUEST)
1185748
public function message() {
		$this->response->disableCache();
		Configure::write('debug', 0);
		if (!$this->RequestHandler->prefers('sse')) {
			throw new BadRequestException();
		}

		$retry = CAKE_NOTIFY_SSE_RETRY;
		$event = 'webNotification';
		$result = [
			'result' => false,
			'messages' => [],
			'retry' => $retry
		];
		if (!$this->Session->started()) {
			$this->Session->renew();
		}

		$userInfo = $this->Auth->user();
		if (empty($userInfo)) {
			$userInfo = [];
		}
		$userId = Hash::get($userInfo, 'id');
		$userRole = Hash::get($userInfo, 'role');
		$prefix = Hash::get($userInfo, 'prefix');

		$lastId = 0;
		if ($this->Session->check('Notifications.lastId')) {
			$lastId = (int)$this->Session->read('Notifications.lastId');
		}

		$notifications = $this->Notification->getNotifications($lastId, $userId, $userRole);
		if (empty($notifications)) {
			$data = json_encode($result);
			$this->set(compact('retry', 'data', 'event'));

			return;
		}

		$iconDefault = '/favicon.ico';
		/*
		$language = new Language();
		$lang = mb_strtoupper($language->getCurrentUiLang(true));
		*/
		foreach ($notifications as $notificationItem) {
			extract($notificationItem['Notification']);
			$lastId = $id;
			$icon = $iconDefault;
			if (isset($data['url']) && is_array($data['url'])) {
				if (!empty($prefix)) {
					$data['url'][$prefix] = true;
				}
				$data['url'] = Router::url($data['url']);
			}
			if (isset($data['icon'])) {
				if (!empty($data['icon'])) {
					$icon = $data['icon'];
				}
				unset($data['icon']);
			}
			$result['messages'][] = compact('tag', 'title', 'body', 'icon', 'data'/*, 'lang'*/);
		}
		if (!empty($result['messages'])) {
			$result['result'] = true;
			$this->Session->write('Notifications.lastId', $lastId);
		}

		$data = json_encode($result);
		$this->set(compact('retry', 'data', 'event'));
	}