Table of Contents

API : PBX : Call test reap

Introduction

Deletes every call test SIP phone that has outlived its 5 minute lifetime. This is what collects the phones left behind by browsers that closed the tab without calling Finish.

Driven once a minute by tcx-scheduler from a ScheduledJobs row. The scheduler impersonates the job's createdBy employee to obtain the bearer token, so that employee must be an ADMIN.

A bounded version of the same sweep also runs inline on each Session request, so a handful of abandoned tabs cannot hold the feature shut until the next scheduled run.

Request

URL https://api.telecomx.dk/pbx/calltest/reap
Method POST
Access level ADMIN

Response

Json object
deleted Number How many phones were deleted.

Example

{
  deleted: 3
}

Scheduler job

db.ScheduledJobs.updateOne(
	{ what: 'PBX_CALL_TEST_REAP' },
	{
		$set: {
			name: 'PBX call test reaper',
			what: 'PBX_CALL_TEST_REAP',
			recurrence: { interval: 'MINUTE', enabled: true },
			hostname: 'api.telecomx.dk',
			path: '/pbx/calltest/reap',
			method: 'POST',
			timeoutMs: 30000,
			createdBy: { _id: ObjectId('55bb161a775e43ef4932dae6'), name: 'Telecom X Admin' }
		},
		$setOnInsert: { _id: new ObjectId(), when: new Date() }
	},
	{ upsert: true }
)

Deliberately no accountId: the scheduler runs at most one job per accountId per cycle, and this job must never be held up behind another one.

Do not insert the job before the API is deployed. The scheduler treats any answered status below 500 as irrecoverable, so a 404 from a route that does not exist yet archives the job into ScheduledJobsFailed and mails - it is not retried, and it will be gone.

Errors

Error code Message Description
401 unauthorized No or invalid token.
403 access_denied Insufficient access level.
500 internal_error <Unspecified>