*
* This is the POST destination for most all locally posted
* text stuff. This function handles status, wall-to-wall status,
- * local comments, and remote coments that are posted on this site
+ * local comments, and remote comments that are posted on this site
* (as opposed to being delivered in a feed).
* Also processed here are posts and comments coming through the
* statusnet/twitter API.
*/
use Friendica\App;
+use Friendica\Content\Conversation;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
-use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
-use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
function item_post(App $a) {
$post['edit'] = $post;
$post['file'] = Post\Category::getTextByURIId($post['uri-id'], $post['uid']);
+ Post\Media::deleteByURIId($post['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE, Post\Media::HTML]);
$post = item_process($post, $request, $preview, $return_path);
$fields = [
if (!empty($request['parent'])) {
$parent_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $request['parent']]);
- if (DBA::isResult($parent_item)) {
+ if ($parent_item) {
// if this isn't the top-level parent of the conversation, find it
if ($parent_item['gravity'] != Item::GRAVITY_PARENT) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $parent_item['parent']]);
Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $post['uid'], 'stored' => $stored]);
}
+ $post['parent'] = $toplevel_item['id'];
$post['gravity'] = Item::GRAVITY_COMMENT;
$post['thr-parent'] = $parent_item['uri'];
$post['wall'] = $toplevel_item['wall'];
} else {
$parent_item = [];
+ $post['parent'] = 0;
$post['gravity'] = Item::GRAVITY_PARENT;
$post['thr-parent'] = $post['uri'];
}
}
$post = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
- if (!DBA::isResult($post)) {
+ if (!$post) {
Logger::error('Item couldn\'t be fetched.', ['post_id' => $post_id]);
if ($return_path) {
DI::baseUrl()->redirect($return_path);
$post = DI::contentItem()->addCategories($post, $request['category'] ?? '');
- if (!$preview) {
- if (Photo::setPermissionFromBody($post['body'], $post['uid'], $post['contact-id'], $post['allow_cid'], $post['allow_gid'], $post['deny_cid'], $post['deny_gid'])) {
- $post['object-type'] = Activity\ObjectType::IMAGE;
- }
-
- $post = DI::contentItem()->moveAttachmentsFromBodyToAttach($post);
- }
-
// Add the attachment to the body.
if (!empty($request['has_attachment'])) {
$post['body'] .= DI::contentItem()->storeAttachmentFromRequest($request);
$post['body'] = BBCode::removeSharedData(Item::setHashtags($post['body']));
$post['writable'] = true;
- $o = DI::conversation()->create([$post], 'search', false, true);
+ $o = DI::conversation()->create([$post], Conversation::MODE_SEARCH, false, true);
System::jsonExit(['preview' => $o]);
}
Contact\User::setBlocked($item['author-id'], DI::userSession()->getLocalUserId(), true);
+ if (DI::mode()->isAjax()) {
+ // ajax return: [<item id>, 0 (no perm) | <owner id>]
+ System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
+ } else {
+ item_redirect_after_action($item, $args->get(3));
+ }
+ break;
+
+ case 'ignore':
+ $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
+ if (empty($item['author-id'])) {
+ throw new HTTPException\NotFoundException('Item not found');
+ }
+
+ Contact\User::setIgnored($item['author-id'], DI::userSession()->getLocalUserId(), true);
+
if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);