diff --git a/doc/Addons.md b/doc/Addons.md index c1861c791..be9dd4218 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -551,10 +551,6 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep- Hook::callAll('about_hook', $o); -### mod/subthread.php - - Hook::callAll('post_local_end', $arr); - ### mod/profiles.php Hook::callAll('profile_post', $_POST); diff --git a/doc/de/Addons.md b/doc/de/Addons.md index 2ff749549..a0ab58de8 100644 --- a/doc/de/Addons.md +++ b/doc/de/Addons.md @@ -259,10 +259,6 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap Hook::callAll('about_hook', $o); -### mod/subthread.php - - Hook::callAll('post_local_end', $arr); - ### mod/profiles.php Hook::callAll('profile_post', $_POST); diff --git a/include/conversation.php b/include/conversation.php index b2353db2a..5b49bc9dc 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -894,7 +894,7 @@ function item_photo_menu($item) { $ignore_link = ''; if (local_user() && local_user() == $item['uid'] && $item['gravity'] == GRAVITY_PARENT && !$item['self']) { - $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; + $sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;'; } $author = ['uid' => 0, 'id' => $item['author-id'], diff --git a/mod/subthread.php b/mod/subthread.php deleted file mode 100644 index 93992d8da..000000000 --- a/mod/subthread.php +++ /dev/null @@ -1,43 +0,0 @@ -. - * - */ - -use Friendica\App; -use Friendica\Network\HTTPException; -use Friendica\Core\Logger; -use Friendica\Core\Session; -use Friendica\Model\Item; -use Friendica\Util\Strings; - -function subthread_content(App $a) -{ - if (!Session::isAuthenticated()) { - throw new HTTPException\ForbiddenException(); - } - - $item_id = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : 0); - - if (!Item::performActivity($item_id, 'follow', local_user())) { - Logger::info('Following item failed', ['item' => $item_id]); - throw new HTTPException\BadRequestException(); - } - Logger::info('Followed item', ['item' => $item_id]); - return; -} diff --git a/src/Module/Item/Follow.php b/src/Module/Item/Follow.php new file mode 100644 index 000000000..ca8aac72b --- /dev/null +++ b/src/Module/Item/Follow.php @@ -0,0 +1,77 @@ +. + * + */ + +namespace Friendica\Module\Item; + +use Friendica\BaseModule; +use Friendica\Core\Session; +use Friendica\Core\System; +use Friendica\DI; +use Friendica\Model\Item; +use Friendica\Model\Post; +use Friendica\Network\HTTPException; + +/** + * Module for following threads + */ +class Follow extends BaseModule +{ + public static function rawContent(array $parameters = []) + { + $l10n = DI::l10n(); + + if (!Session::isAuthenticated()) { + throw new HttpException\ForbiddenException($l10n->t('Access denied.')); + } + + if (empty($parameters['id'])) { + throw new HTTPException\BadRequestException(); + } + + $itemId = intval($parameters['id']); + + if (!Item::performActivity($itemId, 'follow', local_user())) { + throw new HTTPException\BadRequestException($l10n->t('Unable to follow this item.')); + } + + // See if we've been passed a return path to redirect to + $return_path = $_REQUEST['return'] ?? ''; + if (!empty($return_path)) { + $rand = '_=' . time(); + if (strpos($return_path, '?')) { + $rand = "&$rand"; + } else { + $rand = "?$rand"; + } + + DI::baseUrl()->redirect($return_path . $rand); + } + + $return = [ + 'status' => 'ok', + 'item_id' => $itemId, + 'verb' => 'follow', + 'state' => 1 + ]; + + System::jsonExit($return); + } +} diff --git a/static/routes.config.php b/static/routes.config.php index 7d1d9a1bf..afb8ee12f 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -290,11 +290,12 @@ return [ '/testrewrite' => [Module\Install::class, [R::GET]], ], - '/item' => [ - '/{id:\d+}/activity/{verb}' => [Module\Item\Activity::class, [ R::POST]], - '/{id:\d+}/ignore' => [Module\Item\Ignore::class, [ R::POST]], - '/{id:\d+}/pin' => [Module\Item\Pin::class, [ R::POST]], - '/{id:\d+}/star' => [Module\Item\Star::class, [ R::POST]], + '/item/{id:\d+}' => [ + '/activity/{verb}' => [Module\Item\Activity::class, [ R::POST]], + '/follow' => [Module\Item\Follow::class, [ R::POST]], + '/ignore' => [Module\Item\Ignore::class, [ R::POST]], + '/pin' => [Module\Item\Pin::class, [ R::POST]], + '/star' => [Module\Item\Star::class, [ R::POST]], ], '/localtime' => [Module\Debug\Localtime::class, [R::GET, R::POST]], diff --git a/view/js/main.js b/view/js/main.js index 0b9c1da28..4db78f665 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -675,10 +675,10 @@ function doActivityItem(ident, verb, un) { update_item = ident.toString(); } -function dosubthread(ident) { +function doFollowThread(ident) { unpause(); $('#like-rotator-' + ident.toString()).show(); - $.get('subthread/' + ident.toString(), NavUpdate); + $.post('item/' + ident.toString() + '/follow', NavUpdate); liking = 1; } diff --git a/view/theme/frio/templates/search_item.tpl b/view/theme/frio/templates/search_item.tpl index bcd957396..2791a670b 100644 --- a/view/theme/frio/templates/search_item.tpl +++ b/view/theme/frio/templates/search_item.tpl @@ -174,7 +174,7 @@ {{* Put additional actions in a dropdown menu *}} - {{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.subthread || $item.ignore || $item.drop.dropping}} + {{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread || $item.ignore || $item.drop.dropping}} @@ -211,9 +211,9 @@ {{/if}} - {{if $item.subthread}} + {{if $item.follow_thread}}
  • -  {{$item.subthread.title}} +  {{$item.follow_thread.title}}
  • {{/if}} @@ -223,7 +223,7 @@ {{/if}} - {{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.subthread) && ($item.ignore || $item.drop.dropping)}} + {{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread) && ($item.ignore || $item.drop.dropping)}} {{/if}} diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 34d2a7374..52a0e7c48 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -326,7 +326,7 @@ as the value of $top_child_total (this is done at the end of this file) {{/if}} {{* Put additional actions in a dropdown menu *}} - {{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.subthread || $item.ignore || $item.drop.dropping}} + {{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread || $item.ignore || $item.drop.dropping}} @@ -363,9 +363,9 @@ as the value of $top_child_total (this is done at the end of this file) {{/if}} - {{if $item.subthread}} + {{if $item.follow_thread}}
  • -  {{$item.subthread.title}} +  {{$item.follow_thread.title}}
  • {{/if}} @@ -375,7 +375,7 @@ as the value of $top_child_total (this is done at the end of this file) {{/if}} - {{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.subthread) && ($item.ignore || $item.drop.dropping)}} + {{if ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread) && ($item.ignore || $item.drop.dropping)}} {{/if}} @@ -492,7 +492,7 @@ as the value of $top_child_total (this is done at the end of this file) {{/if}} - {{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.subthread || $item.ignore || $item.drop.dropping}} + {{if $item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread || $item.ignore || $item.drop.dropping}}