-/**
- *
- * @param string $type Return type (atom, rss, xml, json)
- *
- * @return array|string
- * @throws BadRequestException
- * @throws ForbiddenException
- * @throws ImagickException
- * @throws InternalServerErrorException
- */
-function api_friendica_activity($type)
-{
- $a = DI::app();
-
- if (api_user() === false) {
- throw new ForbiddenException();
- }
- $verb = strtolower(DI::args()->getArgv()[3]);
- $verb = preg_replace("|\..*$|", "", $verb);
-
- $id = $_REQUEST['id'] ?? 0;
-
- $res = Item::performActivity($id, $verb, api_user());
-
- if ($res) {
- if ($type == "xml") {
- $ok = "true";
- } else {
- $ok = "ok";
- }
- return BaseApi::formatData('ok', $type, ['ok' => $ok]);
- } else {
- throw new BadRequestException('Error adding activity');
- }
-}
-
-/// @TODO move to top of file or somewhere better
-api_register_func('api/friendica/activity/like', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/dislike', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/attendyes', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/attendno', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/attendmaybe', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/unlike', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/undislike', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/unattendyes', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/unattendno', 'api_friendica_activity', true, API_METHOD_POST);
-api_register_func('api/friendica/activity/unattendmaybe', 'api_friendica_activity', true, API_METHOD_POST);
-
-/**
- * Returns notifications
- *
- * @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
- *
- * @return string|array
- * @throws ForbiddenException
- * @throws BadRequestException
- * @throws Exception
- */
-function api_friendica_notification($type)
-{
- if (api_user() === false) {
- throw new ForbiddenException();
- }
- if (DI::args()->getArgc()!==3) {
- throw new BadRequestException('Invalid argument count');
- }
-
- $Notifies = DI::notify()->selectAllForUser(local_user(), 50);
-
- $notifications = new ApiNotifications();
- foreach ($Notifies as $Notify) {
- $notifications[] = new ApiNotification($Notify);
- }
-
- if ($type == 'xml') {
- $xmlnotes = [];
- foreach ($notifications as $notification) {
- $xmlnotes[] = ['@attributes' => $notification->toArray()];
- }
-
- $result = $xmlnotes;
- } elseif (count($notifications) > 0) {
- $result = $notifications->getArrayCopy();
- } else {
- $result = false;
- }
-
- return BaseApi::formatData('notes', $type, ['note' => $result]);
-}
-