mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-03 01:39:31 +02:00
Get update app activities working
This commit is contained in:
parent
cd953319ce
commit
aa141c33a2
3 changed files with 12 additions and 4 deletions
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
import { AppActivityItem, RemovedAppActivityItem, SerializedAppActivityItem, SerializedRemovedAppActivityItem } from '../model/appactivity'
|
||||
import { assertNonEmptyListWithoutDuplicates } from '../util/list'
|
||||
import { assertListWithoutDuplicates } from '../util/list'
|
||||
import { AppLogicAction } from './basetypes'
|
||||
|
||||
export class UpdateAppActivitiesAction extends AppLogicAction {
|
||||
|
@ -29,8 +29,8 @@ export class UpdateAppActivitiesAction extends AppLogicAction {
|
|||
}) {
|
||||
super()
|
||||
|
||||
assertNonEmptyListWithoutDuplicates(removed.map((item) => item.packageName + ':' + item.activityName))
|
||||
assertNonEmptyListWithoutDuplicates(updatedOrAdded.map((item) => item.packageName + ':' + item.activityName))
|
||||
assertListWithoutDuplicates(removed.map((item) => item.packageName + ':' + item.activityName))
|
||||
assertListWithoutDuplicates(updatedOrAdded.map((item) => item.packageName + ':' + item.activityName))
|
||||
|
||||
if (removed.length === 0 && updatedOrAdded.length === 0) {
|
||||
throw new Error('UpdateAppActivitiesAction is empty')
|
||||
|
|
|
@ -39,7 +39,9 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager
|
|||
}) => {
|
||||
const router = Router()
|
||||
|
||||
router.post('/push-actions', json(), async (req, res, next) => {
|
||||
router.post('/push-actions', json({
|
||||
limit: '500kb'
|
||||
}), async (req, res, next) => {
|
||||
try {
|
||||
if (!isClientPushChangesRequest(req.body)) {
|
||||
throw new BadRequest()
|
||||
|
|
|
@ -26,3 +26,9 @@ export function assertNonEmptyListWithoutDuplicates (list: Array<string>) {
|
|||
throw new Error('expected list without duplicates')
|
||||
}
|
||||
}
|
||||
|
||||
export function assertListWithoutDuplicates (list: Array<string>) {
|
||||
if (uniq(list).length !== list.length) {
|
||||
throw new Error('expected list without duplicates')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue