use Friendica\Model\Mail;
use Friendica\Model\Notify;
use Friendica\Model\Photo;
+use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Model\UserItem;
use Friendica\Model\Verb;
use Friendica\Util\Strings;
use Friendica\Util\XML;
-require_once __DIR__ . '/../mod/share.php';
require_once __DIR__ . '/../mod/item.php';
require_once __DIR__ . '/../mod/wall_upload.php';
}
Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call', 'query' => DI::args()->getQueryString()]);
- throw new NotImplementedException();
+ throw new NotFoundException();
} catch (HTTPException $e) {
header("HTTP/1.1 {$e->getCode()} {$e->httpdesc}");
return api_error($type, $e, $args);
*/
function api_get_item(array $condition)
{
- $item = Item::selectFirst(Item::DISPLAY_FIELDLIST, $condition, ['order' => ['id' => true]]);
+ $item = Post::selectFirst(Item::DISPLAY_FIELDLIST, $condition, ['order' => ['id' => true]]);
return $item;
}
}
if (!empty($idarray)) {
- $unseen = Item::exists(['unseen' => true, 'id' => $idarray]);
+ $unseen = Post::exists(['unseen' => true, 'id' => $idarray]);
if ($unseen) {
Item::update(['unseen' => false], ['unseen' => true, 'id' => $idarray]);
}
$conversation = !empty($_REQUEST['conversation']);
// try to fetch the item for the local user - or the public item, if there is no local one
- $uri_item = Item::selectFirst(['uri'], ['id' => $id]);
+ $uri_item = Post::selectFirst(['uri'], ['id' => $id]);
if (!DBA::isResult($uri_item)) {
throw new BadRequestException("There is no status with this id.");
}
- $item = Item::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
+ $item = Post::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
if (!DBA::isResult($item)) {
throw new BadRequestException("There is no status with this id.");
}
Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
// try to fetch the item for the local user - or the public item, if there is no local one
- $item = Item::selectFirst(['parent-uri'], ['id' => $id]);
+ $item = Post::selectFirst(['parent-uri'], ['id' => $id]);
if (!DBA::isResult($item)) {
throw new BadRequestException("There is no status with this id.");
}
- $parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
+ $parent = Post::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
if (!DBA::isResult($parent)) {
throw new BadRequestException("There is no status with this id.");
}
Logger::log('API: api_statuses_repeat: '.$id);
- $fields = ['uri-id', 'body', 'title', 'attach', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
+ $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
$item = Item::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
if (DBA::isResult($item) && $item['body'] != "") {
- if (strpos($item['body'], "[/share]") !== false) {
- $pos = strpos($item['body'], "[share");
- $post = substr($item['body'], $pos);
+ if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) {
+ if (!Item::performActivity($id, 'announce', local_user())) {
+ throw new InternalServerErrorException();
+ }
+
+ $item_id = $id;
} else {
- $post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']);
+ if (strpos($item['body'], "[/share]") !== false) {
+ $pos = strpos($item['body'], "[share");
+ $post = substr($item['body'], $pos);
+ } else {
+ $post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']);
- if (!empty($item['title'])) {
- $post .= '[h3]' . $item['title'] . "[/h3]\n";
+ if (!empty($item['title'])) {
+ $post .= '[h3]' . $item['title'] . "[/h3]\n";
+ }
+
+ $post .= $item['body'];
+ $post .= "[/share]";
}
+ $_REQUEST['body'] = $post;
+ $_REQUEST['profile_uid'] = api_user();
+ $_REQUEST['api_source'] = true;
- $post .= $item['body'];
- $post .= "[/share]";
- }
- $_REQUEST['body'] = $post;
- $_REQUEST['attach'] = $item['attach'];
- $_REQUEST['profile_uid'] = api_user();
- $_REQUEST['api_source'] = true;
+ if (empty($_REQUEST['source'])) {
+ $_REQUEST["source"] = api_source();
+ }
- if (empty($_REQUEST['source'])) {
- $_REQUEST["source"] = api_source();
+ $item_id = item_post($a);
}
-
- $item_id = item_post($a);
-
- /// @todo Copy tags from the original post to the new one
} else {
throw new ForbiddenException();
}
// get last network messages
// params
- $since_id = $_REQUEST['since_id'] ?? 0;
- $max_id = $_REQUEST['max_id'] ?? 0;
- $count = $_REQUEST['count'] ?? 20;
- $page = $_REQUEST['page'] ?? 1;
+ $since_id = intval($_REQUEST['since_id'] ?? 0);
+ $max_id = intval($_REQUEST['max_id'] ?? 0);
+ $count = intval($_REQUEST['count'] ?? 20);
+ $page = intval($_REQUEST['page'] ?? 1);
$start = max(0, ($page - 1) * $count);
$deny_cid = $_REQUEST['deny_cid' ] ?? null;
$allow_gid = $_REQUEST['allow_gid'] ?? null;
$deny_gid = $_REQUEST['deny_gid' ] ?? null;
- $visibility = !empty($_REQUEST['visibility']) && $_REQUEST['visibility'] !== "false";
+ $visibility = !$allow_cid && !$deny_cid && !$allow_gid && !$deny_gid;
// do several checks on input parameters
// we do not allow calls without album string
$arr['guid'] = System::createUUID();
$arr['uid'] = intval(api_user());
$arr['uri'] = $uri;
- $arr['parent-uri'] = $uri;
$arr['type'] = 'photo';
$arr['wall'] = 1;
$arr['resource-id'] = $hash;
// retrieve item element for getting activities (like, dislike etc.) related to photo
$condition = ['uid' => api_user(), 'resource-id' => $photo_id, 'type' => 'photo'];
- $item = Item::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition);
+ $item = Post::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition);
if (!DBA::isResult($item)) {
throw new NotFoundException('Photo-related item not found.');
}
}
if (!empty($condition)) {
- $original_item = Item::selectFirst([], $condition);
+ $original_item = Post::selectFirst([], $condition);
if (DBA::isResult($original_item)) {
$reshared_item = array_merge($reshared_item, $original_item);
}
$in_reply_to['screen_name'] = null;
if (($item['thr-parent'] != $item['uri']) && ($item['gravity'] != GRAVITY_PARENT)) {
- $parent = Item::selectFirst(['id'], ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
+ $parent = Post::selectFirst(['id'], ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
if (DBA::isResult($parent)) {
$in_reply_to['status_id'] = intval($parent['id']);
} else {
$in_reply_to['status_id_str'] = (string) intval($in_reply_to['status_id']);
$fields = ['author-nick', 'author-name', 'author-id', 'author-link'];
- $parent = Item::selectFirst($fields, ['id' => $in_reply_to['status_id']]);
+ $parent = Post::selectFirst($fields, ['id' => $in_reply_to['status_id']]);
if (DBA::isResult($parent)) {
$in_reply_to['screen_name'] = (($parent['author-nick']) ? $parent['author-nick'] : $parent['author-name']);