1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2025-04-08 07:15:43 +02:00

Set lastmodified in read all

if this is not updated the API won't work correctly and we get sync errors.
Adjust test to use item api

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
This commit is contained in:
Benjamin Brahmer 2023-04-03 15:27:21 +02:00
parent f79b6c4751
commit a70d155ce4
4 changed files with 11 additions and 7 deletions

View File

@ -7,6 +7,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1
### Changed
### Fixed
- Fix last_modified not updated when all items are marked as read #2183
# Releases
## [21.2.0-beta1] - 2023-03-23

View File

@ -285,12 +285,15 @@ class ItemMapperV2 extends NewsMapperV2
return intval($value['id']);
}, $this->db->executeQuery($idBuilder->getSQL(), $idBuilder->getParameters())->fetchAll());
$time = new Time();
$builder = $this->db->getQueryBuilder();
$builder->update(self::TABLE_NAME)
->set('unread', $builder->createParameter('unread'))
->set('last_modified', $builder->createParameter('last_modified'))
->andWhere('id IN (:idList)')
->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY)
->setParameter('unread', false, IQueryBuilder::PARAM_BOOL);
->setParameter('unread', false, IQueryBuilder::PARAM_BOOL)
->setParameter('last_modified', $time->getMicroTime(), IQueryBuilder::PARAM_STR);
return $this->db->executeStatement(
$builder->getSQL(),

View File

@ -528,7 +528,7 @@ class ItemMapperTest extends MapperTestUtility
->with('SQL QUERY')
->willReturn($result);
$this->builder->expects($this->once())
$this->builder->expects($this->exactly(2))
->method('createParameter')
->will($this->returnArgument(0));
@ -537,9 +537,9 @@ class ItemMapperTest extends MapperTestUtility
->with('news_items')
->will($this->returnSelf());
$this->builder->expects($this->once())
$this->builder->expects($this->exactly(2))
->method('set')
->with('unread', 'unread')
->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified'])
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))
@ -547,9 +547,9 @@ class ItemMapperTest extends MapperTestUtility
->withConsecutive(['id IN (:idList)'])
->will($this->returnSelf());
$this->builder->expects($this->exactly(2))
$this->builder->expects($this->exactly(3))
->method('setParameter')
->withConsecutive(['idList', [1, 2]], ['unread', false])
->withConsecutive(['idList', [1, 2]], ['unread', false], ['last_modified'])
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))

View File

@ -67,7 +67,7 @@ teardown() {
SYNC_TIME=$(date +%s)
# mark all items of feed as read, returns nothing (other client marks items as read)
STATUS_CODE=$(http --ignore-stdin -hdo /tmp/body -a ${user}:${APP_PASSWORD} PUT ${BASE_URLv1}/feeds/$FEEDID/read newestItemId="$max" 2>&1| grep HTTP/)
STATUS_CODE=$(http --ignore-stdin -hdo /tmp/body -a ${user}:${APP_PASSWORD} PUT ${BASE_URLv1}/items/read newestItemId="$max" 2>&1| grep HTTP/)
# client 2 checks for updates since last sync
UPDATED_ITEMS=($(http --ignore-stdin -b -a ${user}:${APP_PASSWORD} GET ${BASE_URLv1}/items/updated id=$FEEDID lastModified=$SYNC_TIME | grep -Po '"id":\K([0-9]+)' | tr '\n' ' '))