-
- exit();
- }
-
- /**
- * Retrieves the notifications array for the given user ID
- *
- * @param int $uid User id
- * @return array Associative array of notifications
- * @throws HTTPException\InternalServerErrorException
- */
- private function getNotificationList(int $uid): array
- {
- $result = [];
- $offset = 0;
- $seen = false;
- $seensql = 'NOT';
- $order = 'DESC';
- $quit = false;
-
- do {
- $notifies = DBA::toArray(DBA::p(
- "SELECT `notify`.*, `post`.`visible`, `post`.`deleted`
- FROM `notify`
- LEFT JOIN `post` ON `post`.`uri-id` = `notify`.`uri-id`
- WHERE `notify`.`uid` = ? AND `notify`.`msg` != ''
- AND NOT (`notify`.`type` IN (?, ?))
- AND $seensql `notify`.`seen` ORDER BY `notify`.`date` $order LIMIT ?, 50",
- $uid,
- Notification\Type::INTRO,
- Notification\Type::MAIL,
- $offset
- ));
-
- if (!$notifies && !$seen) {
- $seen = true;
- $seensql = '';
- $order = 'DESC';
- $offset = 0;
- } elseif (!$notifies) {
- $quit = true;
- } else {
- $offset += 50;
- }
-
- foreach ($notifies as $notify) {
- $notify['visible'] = $notify['visible'] ?? true;
- $notify['deleted'] = $notify['deleted'] ?? 0;
-
- if ($notify['msg_cache']) {
- $notify['name'] = $notify['name_cache'];
- $notify['message'] = $notify['msg_cache'];
- } else {
- $notify['name'] = strip_tags(BBCode::convert($notify['name']));
- $notify['message'] = BBCode::toPlaintext($notify['msg']);
-
- // @todo Replace this with a call of the Notify model class
- DBA::update('notify', ['name_cache' => $notify['name'], 'msg_cache' => $notify['message']], ['id' => $notify['id']]);
- }
-
- if ($notify['visible']
- && !$notify['deleted']
- && empty($result['p:' . $notify['parent']])
- ) {
- $notification = [
- 'href' => DI::baseUrl() . '/notify/' . $notify['id'],
- 'contact' => [
- 'name' => $notify['name'],
- 'url' => $notify['url'],
- ],
- 'message' => $notify['message'],
- 'date' => $notify['date'],
- 'seen' => $notify['seen'],
- ];
-
- // Should we condense the notifications or show them all?
- if (($notify['verb'] != Activity::POST) || DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
- $result[] = $notification;
- } else {
- $result['p:' . $notify['parent']] = $notification;
- }
- }
- }
- } while ((count($result) < 50) && !$quit);
-
- return($result);