Normalize start_time and end_time parameter names in Friendica API event endpoints

This commit is contained in:
Hypolite Petovan 2022-07-24 05:49:18 -04:00
parent bd02340162
commit 946db2ab45
4 changed files with 50 additions and 46 deletions

View File

@ -410,13 +410,13 @@ Ex: Wed May 23 06:01:13 +0000 2007
</tr>
<tr>
<td><code>startTime</code></td>
<td><code>start_time</code></td>
<td>String (UTC <code>YYYY-MM-DD HH:II:SS)</code>)</td>
<td></td>
</tr>
<tr>
<td><code>endTime</code></td>
<td><code>end_time</code></td>
<td>String (UTC <code>YYYY-MM-DD HH:II:SS)</code>)</td>
<td>Optional (null date is <code>0001-01-01 00:00:00</code></td>
</tr>

View File

@ -32,11 +32,15 @@ Create a new event for the current logged in user.
- `id` : (optional) id of event, event will be amended if supplied
- `name` : name of the event (required)
- `startTime` : start of the event (ISO), required
- `endTime` : (optional) end of the event, event is open end, if not supplied
- `start_time` : start of the event (ISO), required
- `end_time` : (optional) end of the event, event is open end, if not supplied
- `desc` : (optional) description of the event
- `place` : (optional) location of the event
- `publish` : (optional) create message for event
- `allow_cid` : (optional) ACL-formatted list of allowed contact ids if private event
- `allow_gid` : (optional) ACL-formatted list of disallowed contact ids if private event
- `deny_cid` : (optional) ACL-formatted list of allowed group ids if private event
- `deny_gid` : (optional) ACL-formatted list of disallowed group ids if private event
### POST api/friendica/event_delete

View File

@ -48,8 +48,8 @@ class Create extends BaseApi
'id' => 0, //if provided, event will be amended
'name' => '', //summary of the event
'desc' => '', //description in BBCode
'startTime' => '', //starttime, required
'endTime' => '', //endtime, required if nofinish false
'start_time' => '', //start_time, required
'end_time' => '', //endtime, required if nofinish false
'place' => '', //location of the event
'publish' => 0, //publish message
'allow_cid' => '', //array of allowed person, if access restricted
@ -64,20 +64,20 @@ class Create extends BaseApi
}
// error startDate is not specified
if (empty($request['startTime'])) {
if (empty($request['start_time'])) {
throw new HTTPException\BadRequestException('startDate not specified');
}
// nofinish if endTime is not specified
if (empty($request['endTime'])) {
// nofinish if end_time is not specified
if (empty($request['end_time'])) {
$finish = DBA::NULL_DATETIME;
$nofinish = true;
} else {
$finish = DateTimeFormat::convert($request['endTime'], 'UTC', DI::app()->getTimeZone());
$finish = DateTimeFormat::convert($request['end_time'], 'UTC', DI::app()->getTimeZone());
$nofinish = false;
}
$start = DateTimeFormat::convert($request['startTime'], 'UTC', DI::app()->getTimeZone());
$start = DateTimeFormat::convert($request['start_time'], 'UTC', DI::app()->getTimeZone());
// create event
$event = [];
@ -88,8 +88,8 @@ class Create extends BaseApi
$event['summary'] = $request['name'];
$event['desc'] = $request['desc'];
$event['location'] = $request['place'];
$event['start'] = $start;
$event['finish'] = $finish;
$event['start_time'] = $start;
$event['end_time'] = $finish;
$event['nofinish'] = $nofinish;
$event['allow_cid'] = $request['allow_cid'];

View File

@ -55,8 +55,8 @@ class Index extends BaseApi
'uri' => $event['uri'],
'name' => $event['summary'],
'desc' => BBCode::convertForUriId($event['uri-id'], $event['desc']),
'startTime' => $event['start'],
'endTime' => $event['finish'],
'start_time' => $event['start'],
'end_time' => $event['finish'],
'type' => $event['type'],
'nofinish' => $event['nofinish'],
'place' => $event['location'],