mirror of
https://github.com/friendica/friendica
synced 2025-04-26 20:30:11 +00:00
API: Set "dismissed" instead of "seen"
This commit is contained in:
parent
c371d2ec82
commit
f7e859ec2c
10 changed files with 36 additions and 13 deletions
|
@ -68,7 +68,7 @@ class Notifications extends BaseApi
|
|||
|
||||
$params = ['order' => ['id' => true]];
|
||||
|
||||
$condition = ['uid' => $uid, 'seen' => false];
|
||||
$condition = ['uid' => $uid, 'dismissed' => false];
|
||||
|
||||
if (!empty($request['account_id'])) {
|
||||
$contact = Contact::getById($request['account_id'], ['url']);
|
||||
|
|
|
@ -35,7 +35,7 @@ class Clear extends BaseApi
|
|||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
$uid = self::getCurrentUserID();
|
||||
|
||||
DI::notification()->setAllSeenForUser($uid);
|
||||
DI::notification()->setAllDismissedForUser($uid);
|
||||
|
||||
System::jsonExit([]);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class Dismiss extends BaseApi
|
|||
}
|
||||
|
||||
$Notification = DI::notification()->selectOneForUser($uid, $this->parameters['id']);
|
||||
$Notification->setSeen();
|
||||
$Notification->setDismissed();
|
||||
DI::notification()->save($Notification);
|
||||
|
||||
System::jsonExit([]);
|
||||
|
|
|
@ -40,4 +40,11 @@ class Notifications extends BaseCollection
|
|||
$Notification->setSeen();
|
||||
});
|
||||
}
|
||||
|
||||
public function setDismissed(): Notifications
|
||||
{
|
||||
return $this->map(function (Entity\Notification $Notification) {
|
||||
$Notification->setDismissed();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ class Notification extends BaseEntity
|
|||
protected $created;
|
||||
/** @var bool */
|
||||
protected $seen;
|
||||
/** @var bool */
|
||||
protected $dismissed;
|
||||
|
||||
/**
|
||||
* Please do not use this constructor directly, instead use one of the method of the Notification factory.
|
||||
|
@ -52,9 +54,10 @@ class Notification extends BaseEntity
|
|||
* @param DateTime|null $created
|
||||
* @param bool $seen
|
||||
* @param int|null $id
|
||||
* @param bool $dismissed
|
||||
* @see \Friendica\Navigation\Notifications\Factory\Notification
|
||||
*/
|
||||
public function __construct(int $uid, string $verb, int $type, int $actorId, int $targetUriId = null, int $parentUriId = null, DateTime $created = null, bool $seen = false, int $id = null)
|
||||
public function __construct(int $uid, string $verb, int $type, int $actorId, int $targetUriId = null, int $parentUriId = null, DateTime $created = null, bool $seen = false, int $id = null, bool $dismissed = false)
|
||||
{
|
||||
$this->uid = $uid;
|
||||
$this->verb = $verb;
|
||||
|
@ -65,10 +68,16 @@ class Notification extends BaseEntity
|
|||
$this->created = $created;
|
||||
$this->seen = $seen;
|
||||
$this->id = $id;
|
||||
$this->dismissed = $dismissed;
|
||||
}
|
||||
|
||||
public function setSeen()
|
||||
{
|
||||
$this->seen = true;
|
||||
}
|
||||
|
||||
public function setDismissed()
|
||||
{
|
||||
$this->dismissed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,13 @@ class Notification extends BaseRepository
|
|||
return $this->db->update(self::$table_name, ['seen' => true], $condition);
|
||||
}
|
||||
|
||||
public function setAllDismissedForUser(int $uid, array $condition = []): bool
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition, ['uid' => $uid]);
|
||||
|
||||
return $this->db->update(self::$table_name, ['dismissed' => true], $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entity\Notification $Notification
|
||||
* @return Entity\Notification
|
||||
|
@ -125,6 +132,7 @@ class Notification extends BaseRepository
|
|||
'target-uri-id' => $Notification->targetUriId,
|
||||
'parent-uri-id' => $Notification->parentUriId,
|
||||
'seen' => $Notification->seen,
|
||||
'dismissed' => $Notification->dismissed,
|
||||
];
|
||||
|
||||
if ($Notification->id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue