mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:00:16 +00:00
Issue 5158: Ignore all threads, even public ones (#5588)
* Issue 5158: Ignore all threads, even public ones * Remove some notice * Now it really should work * Using "defaults"
This commit is contained in:
parent
50e1512014
commit
276abfaba6
7 changed files with 61 additions and 44 deletions
2
boot.php
2
boot.php
|
@ -41,7 +41,7 @@ define('FRIENDICA_PLATFORM', 'Friendica');
|
|||
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
|
||||
define('FRIENDICA_VERSION', '2018.08-dev');
|
||||
define('DFRN_PROTOCOL_VERSION', '2.23');
|
||||
define('DB_UPDATE_VERSION', 1281);
|
||||
define('DB_UPDATE_VERSION', 1282);
|
||||
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1229,7 +1229,8 @@
|
|||
"fields": {
|
||||
"iid": {"type": "int unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"item": "id"}, "comment": "Item id"},
|
||||
"uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"user": "uid"}, "comment": "User id"},
|
||||
"hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": "Marker to hide an item from the user"}
|
||||
"hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": "Marker to hide an item from the user"},
|
||||
"ignored": {"type": "boolean", "comment": "Ignore this thread if set"}
|
||||
},
|
||||
"indexes": {
|
||||
"PRIMARY": ["uid", "iid"]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2018.08-dev (The Tazmans Flax-lily)
|
||||
-- DB_UPDATE_VERSION 1281
|
||||
-- DB_UPDATE_VERSION 1282
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -1180,6 +1180,7 @@ CREATE TABLE IF NOT EXISTS `user-item` (
|
|||
`iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
|
||||
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
|
||||
`hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
|
||||
`ignored` boolean COMMENT 'Ignore this thread if set',
|
||||
PRIMARY KEY(`uid`,`iid`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ function notification($params)
|
|||
}
|
||||
|
||||
if ($params['type'] == NOTIFY_COMMENT) {
|
||||
$thread = DBA::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
|
||||
$thread = Item::selectFirstThreadForUser($params['uid'] ,['ignored'], ['iid' => $parent_id]);
|
||||
if (DBA::isResult($thread) && $thread["ignored"]) {
|
||||
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
|
||||
return;
|
||||
|
@ -814,13 +814,10 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
|||
}
|
||||
|
||||
// Is it a post that the user had started or where he interacted?
|
||||
$parent = q("SELECT `thread`.`iid` FROM `thread` INNER JOIN `item` ON `item`.`parent` = `thread`.`iid`
|
||||
WHERE `thread`.`iid` = %d AND NOT `thread`.`ignored` AND
|
||||
(`thread`.`mention` OR `item`.`author-id` IN ($contact_list))
|
||||
LIMIT 1",
|
||||
intval($item["parent"]));
|
||||
$fields = ['ignored', 'mention', 'author-id'];
|
||||
$thread = Item::selectFirstThreadForUser($params['uid'], $fields, ['iid' => $item["parent"]]);
|
||||
|
||||
if ($parent && !isset($params["type"])) {
|
||||
if (($thread['mention'] || in_array($thread['author-id'], $contacts)) && !$thread['ignored'] && !isset($params["type"])) {
|
||||
$params["type"] = NOTIFY_COMMENT;
|
||||
$params["verb"] = ACTIVITY_POST;
|
||||
}
|
||||
|
|
|
@ -3,45 +3,48 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
||||
function ignored_init(App $a) {
|
||||
|
||||
function ignored_init(App $a)
|
||||
{
|
||||
$ignored = 0;
|
||||
|
||||
if (! local_user()) {
|
||||
if (!local_user()) {
|
||||
killme();
|
||||
}
|
||||
|
||||
if ($a->argc > 1) {
|
||||
$message_id = intval($a->argv[1]);
|
||||
}
|
||||
if (! $message_id) {
|
||||
|
||||
if (!$message_id) {
|
||||
killme();
|
||||
}
|
||||
|
||||
$r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
|
||||
intval(local_user()),
|
||||
intval($message_id)
|
||||
);
|
||||
if (! DBA::isResult($r)) {
|
||||
$thread = Item::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $message_id]);
|
||||
if (!DBA::isResult($thread)) {
|
||||
killme();
|
||||
}
|
||||
|
||||
if (! intval($r[0]['ignored'])) {
|
||||
$ignored = 1;
|
||||
if (!$thread['ignored']) {
|
||||
$ignored = true;
|
||||
}
|
||||
|
||||
$r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d",
|
||||
intval($ignored),
|
||||
intval(local_user()),
|
||||
intval($message_id)
|
||||
);
|
||||
if ($thread['uid'] != 0) {
|
||||
DBA::update('thread', ['ignored' => $ignored], ['iid' => $message_id]);
|
||||
} else {
|
||||
DBA::update('user-item', ['ignored' => $ignored], ['iid' => $message_id, 'uid' => local_user()], true);
|
||||
}
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
|
||||
$return_path = defaults($_REQUEST, 'return', '');
|
||||
if ($return_path) {
|
||||
$rand = '_=' . time();
|
||||
if(strpos($return_path, '?')) $rand = "&$rand";
|
||||
else $rand = "?$rand";
|
||||
if (strpos($return_path, '?')) {
|
||||
$rand = "&$rand";
|
||||
} else {
|
||||
$rand = "?$rand";
|
||||
}
|
||||
|
||||
goaway(System::baseUrl() . "/" . $return_path . $rand);
|
||||
}
|
||||
|
|
|
@ -230,12 +230,17 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('ignored', $row) && array_key_exists('internal-user-ignored', $row) && !is_null($row['internal-user-ignored'])) {
|
||||
$row['ignored'] = $row['internal-user-ignored'];
|
||||
}
|
||||
|
||||
// Remove internal fields
|
||||
unset($row['internal-activity']);
|
||||
unset($row['internal-network']);
|
||||
unset($row['internal-iid']);
|
||||
unset($row['internal-iaid']);
|
||||
unset($row['internal-icid']);
|
||||
unset($row['internal-user-ignored']);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
@ -369,7 +374,7 @@ class Item extends BaseObject
|
|||
$usermode = true;
|
||||
}
|
||||
|
||||
$fields = self::fieldlist($selected);
|
||||
$fields = self::fieldlist($selected, $usermode);
|
||||
|
||||
$select_fields = self::constructSelectFields($fields, $selected);
|
||||
|
||||
|
@ -476,7 +481,9 @@ class Item extends BaseObject
|
|||
$usermode = true;
|
||||
}
|
||||
|
||||
$fields = self::fieldlist($selected);
|
||||
$fields = self::fieldlist($selected, $usermode);
|
||||
|
||||
$fields['thread'] = ['mention', 'ignored', 'iid'];
|
||||
|
||||
$threadfields = ['thread' => ['iid', 'uid', 'contact-id', 'owner-id', 'author-id',
|
||||
'created', 'edited', 'commented', 'received', 'changed', 'wall', 'private',
|
||||
|
@ -510,7 +517,7 @@ class Item extends BaseObject
|
|||
*
|
||||
* @return array field list
|
||||
*/
|
||||
private static function fieldlist($selected)
|
||||
private static function fieldlist($selected, $usermode)
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
|
@ -524,6 +531,10 @@ class Item extends BaseObject
|
|||
'network' => 'internal-network', 'icid' => 'internal-icid',
|
||||
'iaid' => 'internal-iaid'];
|
||||
|
||||
if ($usermode) {
|
||||
$fields['user-item'] = ['ignored' => 'internal-user-ignored'];
|
||||
}
|
||||
|
||||
$fields['item-activity'] = ['activity', 'activity' => 'internal-activity'];
|
||||
|
||||
$fields['item-content'] = array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST);
|
||||
|
@ -681,6 +692,10 @@ class Item extends BaseObject
|
|||
$selected[] = 'internal-activity';
|
||||
}
|
||||
|
||||
if (in_array('ignored', $selected)) {
|
||||
$selected[] = 'internal-user-ignored';
|
||||
}
|
||||
|
||||
$selection = [];
|
||||
foreach ($fields as $table => $table_fields) {
|
||||
foreach ($table_fields as $field => $select) {
|
||||
|
|
|
@ -252,6 +252,18 @@ class Post extends BaseObject
|
|||
$tagger = '';
|
||||
|
||||
if ($this->isToplevel()) {
|
||||
$thread = Item::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]);
|
||||
if (DBA::isResult($thread)) {
|
||||
$ignore = [
|
||||
'do' => L10n::t("ignore thread"),
|
||||
'undo' => L10n::t("unignore thread"),
|
||||
'toggle' => L10n::t("toggle ignore status"),
|
||||
'classdo' => $thread['ignored'] ? "hidden" : "",
|
||||
'classundo' => $thread['ignored'] ? "" : "hidden",
|
||||
'ignored' => L10n::t('ignored'),
|
||||
];
|
||||
}
|
||||
|
||||
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
|
||||
$isstarred = (($item['starred']) ? "starred" : "unstarred");
|
||||
|
||||
|
@ -264,18 +276,6 @@ class Post extends BaseObject
|
|||
'starred' => L10n::t('starred'),
|
||||
];
|
||||
|
||||
$thread = DBA::selectFirst('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
|
||||
if (DBA::isResult($thread)) {
|
||||
$ignore = [
|
||||
'do' => L10n::t("ignore thread"),
|
||||
'undo' => L10n::t("unignore thread"),
|
||||
'toggle' => L10n::t("toggle ignore status"),
|
||||
'classdo' => $thread['ignored'] ? "hidden" : "",
|
||||
'classundo' => $thread['ignored'] ? "" : "hidden",
|
||||
'ignored' => L10n::t('ignored'),
|
||||
];
|
||||
}
|
||||
|
||||
if (Feature::isEnabled($conv->getProfileOwner(), 'commtag')) {
|
||||
$tagger = [
|
||||
'add' => L10n::t("add tag"),
|
||||
|
|
Loading…
Reference in a new issue