Merge pull request #8194 from nupplaphil/bug/ignore_notification
Fix ignore notification
This commit is contained in:
commit
db9f75fbdb
9 changed files with 37 additions and 43 deletions
|
@ -500,7 +500,7 @@ function notification($params)
|
||||||
|
|
||||||
DI::notify()->update($notification);
|
DI::notify()->update($notification);
|
||||||
|
|
||||||
$itemlink = DI::baseUrl() . '/notification/view/' . $notification->id;
|
$itemlink = DI::baseUrl() . '/notification/' . $notification->id;
|
||||||
$notify_id = $notification->id;
|
$notify_id = $notification->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -443,7 +443,7 @@ function ping_get_notifications($uid)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification["href"] = DI::baseUrl() . "/notification/view/" . $notification["id"];
|
$notification["href"] = DI::baseUrl() . "/notification/" . $notification["id"];
|
||||||
|
|
||||||
if ($notification["visible"]
|
if ($notification["visible"]
|
||||||
&& !$notification["deleted"]
|
&& !$notification["deleted"]
|
||||||
|
|
|
@ -219,7 +219,7 @@ class Notification extends BaseFactory
|
||||||
foreach ($notifications as $notification) {
|
foreach ($notifications as $notification) {
|
||||||
$formattedNotifications[] = new \Friendica\Object\Notification\Notification([
|
$formattedNotifications[] = new \Friendica\Object\Notification\Notification([
|
||||||
'label' => 'notification',
|
'label' => 'notification',
|
||||||
'link' => $this->baseUrl->get(true) . '/notification/view/' . $notification->id,
|
'link' => $this->baseUrl->get(true) . '/notification/' . $notification->id,
|
||||||
'image' => Proxy::proxifyUrl($notification->photo, false, Proxy::SIZE_MICRO),
|
'image' => Proxy::proxifyUrl($notification->photo, false, Proxy::SIZE_MICRO),
|
||||||
'url' => $notification->url,
|
'url' => $notification->url,
|
||||||
'text' => strip_tags(BBCode::convert($notification->msg)),
|
'text' => strip_tags(BBCode::convert($notification->msg)),
|
||||||
|
|
|
@ -75,30 +75,6 @@ abstract class BaseNotifications extends BaseModule
|
||||||
self::$showAll = ($_REQUEST['show'] ?? '') === 'all';
|
self::$showAll = ($_REQUEST['show'] ?? '') === 'all';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function post(array $parameters = [])
|
|
||||||
{
|
|
||||||
$request_id = DI::args()->get(1);
|
|
||||||
|
|
||||||
if ($request_id === 'all') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request_id) {
|
|
||||||
$intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]);
|
|
||||||
|
|
||||||
switch ($_POST['submit']) {
|
|
||||||
case DI::l10n()->t('Discard'):
|
|
||||||
$intro->discard();
|
|
||||||
break;
|
|
||||||
case DI::l10n()->t('Ignore'):
|
|
||||||
$intro->ignore();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DI::baseUrl()->redirect('notifications/intros');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function rawContent(array $parameters = [])
|
public static function rawContent(array $parameters = [])
|
||||||
{
|
{
|
||||||
// If the last argument of the query is NOT json, return
|
// If the last argument of the query is NOT json, return
|
||||||
|
|
|
@ -19,6 +19,26 @@ class Notification extends BaseModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function post(array $parameters = [])
|
||||||
|
{
|
||||||
|
$request_id = $parameters['id'] ?? false;
|
||||||
|
|
||||||
|
if ($request_id) {
|
||||||
|
$intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]);
|
||||||
|
|
||||||
|
switch ($_POST['submit']) {
|
||||||
|
case DI::l10n()->t('Discard'):
|
||||||
|
$intro->discard();
|
||||||
|
break;
|
||||||
|
case DI::l10n()->t('Ignore'):
|
||||||
|
$intro->ignore();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DI::baseUrl()->redirect('notifications/intros');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function rawContent(array $parameters = [])
|
public static function rawContent(array $parameters = [])
|
||||||
{
|
{
|
||||||
// @TODO: Replace with parameter from router
|
// @TODO: Replace with parameter from router
|
||||||
|
@ -26,14 +46,11 @@ class Notification extends BaseModule
|
||||||
try {
|
try {
|
||||||
$success = DI::notify()->setAllSeen();
|
$success = DI::notify()->setAllSeen();
|
||||||
}catch (\Exception $e) {
|
}catch (\Exception $e) {
|
||||||
|
DI::logger()->warning('set all seen failed.', ['exception' => $e]);
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-type: application/json; charset=utf-8');
|
System::jsonExit(['result' => (($success) ? 'success' : 'fail')]);
|
||||||
echo json_encode([
|
|
||||||
'result' => ($success) ? 'success' : 'fail',
|
|
||||||
]);
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +62,11 @@ class Notification extends BaseModule
|
||||||
*/
|
*/
|
||||||
public static function content(array $parameters = [])
|
public static function content(array $parameters = [])
|
||||||
{
|
{
|
||||||
// @TODO: Replace with parameter from router
|
$request_id = $parameters['id'] ?? false;
|
||||||
if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) {
|
|
||||||
|
if ($request_id) {
|
||||||
try {
|
try {
|
||||||
$notification = DI::notify()->getByID(DI::args()->get(2));
|
$notification = DI::notify()->getByID($request_id);
|
||||||
$notification->setSeen();
|
$notification->setSeen();
|
||||||
|
|
||||||
if (!empty($notification->link)) {
|
if (!empty($notification->link)) {
|
||||||
|
@ -62,7 +80,7 @@ class Notification extends BaseModule
|
||||||
DI::baseUrl()->redirect();
|
DI::baseUrl()->redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: Replace with parameter from router
|
|
||||||
DI::baseUrl()->redirect('notifications/system');
|
DI::baseUrl()->redirect('notifications/system');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,8 +185,8 @@ return [
|
||||||
|
|
||||||
'/notification' => [
|
'/notification' => [
|
||||||
'[/]' => [Module\Notifications\Notification::class, [R::GET]],
|
'[/]' => [Module\Notifications\Notification::class, [R::GET]],
|
||||||
'/view/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET]],
|
|
||||||
'/mark/all' => [Module\Notifications\Notification::class, [R::GET]],
|
'/mark/all' => [Module\Notifications\Notification::class, [R::GET]],
|
||||||
|
'/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET, R::POST]],
|
||||||
],
|
],
|
||||||
'/objects/{guid}' => [Module\Objects::class, [R::GET]],
|
'/objects/{guid}' => [Module\Objects::class, [R::GET]],
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="intro-knowyou">{{$lbl_knowyou}} {{$knowyou}}</div>
|
<div class="intro-knowyou">{{$lbl_knowyou}} {{$knowyou}}</div>
|
||||||
<div class="intro-note" id="intro-note-{{$contact_id}}">{{$note}}</div>
|
<div class="intro-note" id="intro-note-{{$contact_id}}">{{$note}}</div>
|
||||||
<div class="intro-wrapper-end" id="intro-wrapper-end-{{$contact_id}}"></div>
|
<div class="intro-wrapper-end" id="intro-wrapper-end-{{$contact_id}}"></div>
|
||||||
<form class="intro-form" action="notifications/{{$intro_id}}" method="post">
|
<form class="intro-form" action="notification/{{$intro_id}}" method="post">
|
||||||
<input class="intro-submit-ignore" type="submit" name="submit" value="{{$ignore}}" />
|
<input class="intro-submit-ignore" type="submit" name="submit" value="{{$ignore}}" />
|
||||||
{{if $discard}}<input class="intro-submit-discard" type="submit" name="submit" value="{{$discard}}" />{{/if}}
|
{{if $discard}}<input class="intro-submit-discard" type="submit" name="submit" value="{{$discard}}" />{{/if}}
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<a class="intro-url-link" href="{{$url}}" ><img class="intro-photo lframe" src="{{$photo}}" width="175" height="175" title="{{$fullname}}" alt="{{$fullname}}" /></a>
|
<a class="intro-url-link" href="{{$url}}" ><img class="intro-photo lframe" src="{{$photo}}" width="175" height="175" title="{{$fullname}}" alt="{{$fullname}}" /></a>
|
||||||
<div class="intro-note" >{{$note}}</div>
|
<div class="intro-note" >{{$note}}</div>
|
||||||
<div class="intro-wrapper-end"></div>
|
<div class="intro-wrapper-end"></div>
|
||||||
<form class="intro-form" action="notifications/{{$intro_id}}" method="post">
|
<form class="intro-form" action="notification/{{$intro_id}}" method="post">
|
||||||
<input class="intro-submit-ignore" type="submit" name="submit" value="{{$ignore}}" />
|
<input class="intro-submit-ignore" type="submit" name="submit" value="{{$ignore}}" />
|
||||||
<input class="intro-submit-discard" type="submit" name="submit" value="{{$discard}}" />
|
<input class="intro-submit-discard" type="submit" name="submit" value="{{$discard}}" />
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<div class="intro-actions pull-right nav-pills preferences">
|
<div class="intro-actions pull-right nav-pills preferences">
|
||||||
<button class="btn-link intro-action-link" onclick="addElmToModal('#intro-approve-wrapper-{{$intro_id}}');" aria-label="{{$approve}}" title="{{$approve}}" data-toggle="tooltip"><i class="fa fa-check" aria-hidden="true"></i></button>
|
<button class="btn-link intro-action-link" onclick="addElmToModal('#intro-approve-wrapper-{{$intro_id}}');" aria-label="{{$approve}}" title="{{$approve}}" data-toggle="tooltip"><i class="fa fa-check" aria-hidden="true"></i></button>
|
||||||
|
|
||||||
<form class="intro-form" action="notifications/{{$intro_id}}" method="post">
|
<form class="intro-form" action="notification/{{$intro_id}}" method="post">
|
||||||
<button class="btn-link intro-submit-ignore intro-action-link" type="submit" name="submit" value="{{$ignore}}" aria-label="{{$ignore}}" title="{{$ignore}}" data-toggle="tooltip"><i class="fa fa-ban" aria-hidden="true"></i></button>
|
<button class="btn-link intro-submit-ignore intro-action-link" type="submit" name="submit" value="{{$ignore}}" aria-label="{{$ignore}}" title="{{$ignore}}" data-toggle="tooltip"><i class="fa fa-ban" aria-hidden="true"></i></button>
|
||||||
{{if $discard}}<button class="btn-link intro-submit-discard intro-action-link" type="submit" name="submit" value="{{$discard}}" aria-label="{{$discard}}" title="{{$discard}}" data-toggle="tooltip"><i class="fa fa-trash-o" aria-hidden="true"></i></button>{{/if}}
|
{{if $discard}}<button class="btn-link intro-submit-discard intro-action-link" type="submit" name="submit" value="{{$discard}}" aria-label="{{$discard}}" title="{{$discard}}" data-toggle="tooltip"><i class="fa fa-trash-o" aria-hidden="true"></i></button>{{/if}}
|
||||||
</form>
|
</form>
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
{{* On mobile touch devices we use buttons for approve, ingnore && discard to have a better UX *}}
|
{{* On mobile touch devices we use buttons for approve, ingnore && discard to have a better UX *}}
|
||||||
{{if $APP->is_mobile}}
|
{{if $APP->is_mobile}}
|
||||||
<div class="intro-action-buttons">
|
<div class="intro-action-buttons">
|
||||||
<form class="intro-form pull-left" action="notifications/{{$intro_id}}" method="post">
|
<form class="intro-form pull-left" action="notification/{{$intro_id}}" method="post">
|
||||||
<button class="btn btn-small btn-default intro-submit-ignore" type="submit" name="submit" value="{{$ignore}}">{{$ignore}}</button>
|
<button class="btn btn-small btn-default intro-submit-ignore" type="submit" name="submit" value="{{$ignore}}">{{$ignore}}</button>
|
||||||
{{if $discard}}<button class="btn btn-small btn-default intro-submit-discard" type="submit" name="submit" value="{{$discard}}">{{$discard}}</button> {{/if}}
|
{{if $discard}}<button class="btn btn-small btn-default intro-submit-discard" type="submit" name="submit" value="{{$discard}}">{{$discard}}</button> {{/if}}
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue