mirror of
https://github.com/friendica/friendica
synced 2024-12-23 04:00:15 +00:00
Block tags from the trending tags
This commit is contained in:
parent
1716ea7101
commit
639a781125
2 changed files with 27 additions and 2 deletions
|
@ -518,6 +518,23 @@ class Tag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the blocked tags as SQL
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function getBlockedSQL()
|
||||||
|
{
|
||||||
|
$blocked_txt = DI::config()->get('system', 'blocked_tags');
|
||||||
|
if (empty($blocked_txt)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$blocked = explode(',', $blocked_txt);
|
||||||
|
array_walk($blocked, function(&$value) { $value = "'" . DBA::escape(trim($value)) . "'";});
|
||||||
|
return " AND NOT `name` IN (" . implode(',', $blocked) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a list of the most frequent global hashtags over the given period
|
* Creates a list of the most frequent global hashtags over the given period
|
||||||
*
|
*
|
||||||
|
@ -528,9 +545,11 @@ class Tag
|
||||||
*/
|
*/
|
||||||
public static function setGlobalTrendingHashtags(int $period, int $limit = 10)
|
public static function setGlobalTrendingHashtags(int $period, int $limit = 10)
|
||||||
{
|
{
|
||||||
|
$block_sql = self::getBlockedSQL();
|
||||||
|
|
||||||
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`
|
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`
|
||||||
FROM `tag-search-view`
|
FROM `tag-search-view`
|
||||||
WHERE `private` = ? AND `uid` = ? AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR)
|
WHERE `private` = ? AND `uid` = ? AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR) $block_sql
|
||||||
GROUP BY `term` ORDER BY `score` DESC LIMIT ?",
|
GROUP BY `term` ORDER BY `score` DESC LIMIT ?",
|
||||||
Item::PUBLIC, 0, $period, $limit);
|
Item::PUBLIC, 0, $period, $limit);
|
||||||
|
|
||||||
|
@ -571,9 +590,11 @@ class Tag
|
||||||
*/
|
*/
|
||||||
public static function setLocalTrendingHashtags(int $period, int $limit = 10)
|
public static function setLocalTrendingHashtags(int $period, int $limit = 10)
|
||||||
{
|
{
|
||||||
|
$block_sql = self::getBlockedSQL();
|
||||||
|
|
||||||
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`
|
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`
|
||||||
FROM `tag-search-view`
|
FROM `tag-search-view`
|
||||||
WHERE `private` = ? AND `wall` AND `origin` AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR)
|
WHERE `private` = ? AND `wall` AND `origin` AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR) $block_sql
|
||||||
GROUP BY `term` ORDER BY `score` DESC LIMIT ?",
|
GROUP BY `term` ORDER BY `score` DESC LIMIT ?",
|
||||||
Item::PUBLIC, $period, $limit);
|
Item::PUBLIC, $period, $limit);
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,10 @@ return [
|
||||||
// Deny public access to the local user directory.
|
// Deny public access to the local user directory.
|
||||||
'block_local_dir' => false,
|
'block_local_dir' => false,
|
||||||
|
|
||||||
|
// blocked_tags (String)
|
||||||
|
// Comma separated list of hash tags that shouldn't be displayed in the trending tags
|
||||||
|
'blocked_tags' => '',
|
||||||
|
|
||||||
// community_no_sharer (Boolean)
|
// community_no_sharer (Boolean)
|
||||||
// Don't display sharing accounts on the global community
|
// Don't display sharing accounts on the global community
|
||||||
'community_no_sharer' => false,
|
'community_no_sharer' => false,
|
||||||
|
|
Loading…
Reference in a new issue