diff --git a/doc/API-Entities.md b/doc/API-Entities.md index b234912ac..e369cb4ff 100644 --- a/doc/API-Entities.md +++ b/doc/API-Entities.md @@ -361,6 +361,123 @@ Ex: Wed May 23 06:01:13 +0000 2007 +## Event + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeDescription
idInteger
uidIntegerOwner User Id
cidIntegerTarget Contact Id
uriStringItem unique URI string
nameString (Plaintext)Title
descString (HTML)Description
startTimeString (UTC YYYY-MM-DD HH:II:SS))
endTimeString (UTC YYYY-MM-DD HH:II:SS))Optional (null date is 0001-01-01 00:00:00
typeString (event or birthday)
nofinishBooleanOngoing event
placeStringOptional. Location.
adjustBoolean???
ignoreBoolean???
allow_cidString (angle-brackets escaped integers)Optional. List of allowed contact ids
allow_gidString (angle-brackets escaped integers)Optional. List of allowed group ids
deny_cidString (angle-brackets escaped integers)Optional. List of disallowed contact ids
deny_gidString (angle-brackets escaped integers)Optional. List of disallowed group ids
+ ## Hashtag Unused diff --git a/doc/API-Friendica.md b/doc/API-Friendica.md index 013dd08f5..62a71dc6b 100644 --- a/doc/API-Friendica.md +++ b/doc/API-Friendica.md @@ -15,6 +15,15 @@ These endpoints uses the [Friendica API entities](help/API-Entities). ## Endpoints +### GET api/friendica/events + +Returns a list of [Event](help/API-Entities#Event) entities for the current logged in user. + +#### Parameters + +- `since_id`: (optional) minimum event id for pagination +- `count`: maximum number of items returned, default 20 + ### GET api/externalprofile/show Returns a [Contact](help/API-Entities#Contact) entity for the provided profile URL. diff --git a/src/Module/Api/Friendica/Events/Index.php b/src/Module/Api/Friendica/Events/Index.php new file mode 100644 index 000000000..f5924e8a0 --- /dev/null +++ b/src/Module/Api/Friendica/Events/Index.php @@ -0,0 +1,75 @@ +. + * + */ + +namespace Friendica\Module\Api\Friendica\Events; + +use Friendica\Content\Text\BBCode; +use Friendica\Database\DBA; +use Friendica\Module\BaseApi; +use Friendica\Network\HTTPException; + +/** + * api/friendica/events + * + * @package Friendica\Module\Api\Friendica\Events + */ +class Index extends BaseApi +{ + public static function rawContent(array $parameters = []) + { + if (self::login() === false) { + throw new HTTPException\ForbiddenException(); + } + + $since_id = $_REQUEST['since_id'] ?? 0; + $count = $_REQUEST['count'] ?? 20; + + $condition = ["`id` > ? AND `uid` = ?", $since_id, self::$current_user_id]; + $params = ['limit' => $count]; + $events = DBA::selectToArray('event', [], $condition, $params); + + $items = []; + foreach ($events as $event) { + $items[] = [ + 'id' => intval($event['id']), + 'uid' => intval($event['uid']), + 'cid' => $event['cid'], + 'uri' => $event['uri'], + 'name' => $event['summary'], + 'desc' => BBCode::convert($event['desc']), + 'startTime' => $event['start'], + 'endTime' => $event['finish'], + 'type' => $event['type'], + 'nofinish' => $event['nofinish'], + 'place' => $event['location'], + 'adjust' => $event['adjust'], + 'ignore' => $event['ignore'], + 'allow_cid' => $event['allow_cid'], + 'allow_gid' => $event['allow_gid'], + 'deny_cid' => $event['deny_cid'], + 'deny_gid' => $event['deny_gid'] + ]; + } + + echo self::format('events', ['events' => $items]); + exit; + } +} diff --git a/static/routes.config.php b/static/routes.config.php index d0a1bde76..6e23e238e 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -55,6 +55,7 @@ return [ ], '/friendica' => [ '/profile/show' => [Module\Api\Friendica\Profile\Show::class , [R::GET ]], + '/events' => [Module\Api\Friendica\Events\Index::class , [R::GET ]], ], ],