Merge pull request #10372 from annando/forum-handling

Improved forum handling
This commit is contained in:
Hypolite Petovan 2021-06-05 16:48:55 -04:00 committed by GitHub
commit 49b9505972
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 22 deletions

View file

@ -40,6 +40,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\APContact;
use Friendica\Model\Attach; use Friendica\Model\Attach;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation; use Friendica\Model\Conversation;
@ -436,8 +437,13 @@ function item_post(App $a) {
if (!$toplevel_item_id && !empty($forum_contact) && ($private_forum || $only_to_forum)) { if (!$toplevel_item_id && !empty($forum_contact) && ($private_forum || $only_to_forum)) {
// we tagged a forum in a top level post. Now we change the post // we tagged a forum in a top level post. Now we change the post
$private = $private_forum; $private = $private_forum ? Item::PRIVATE : Item::UNLISTED;
if ($only_to_forum) {
$postopts = '';
}
if ($private_forum || !APContact::getByURL($forum_contact['url'])) {
$str_group_allow = ''; $str_group_allow = '';
$str_contact_deny = ''; $str_contact_deny = '';
$str_group_deny = ''; $str_group_deny = '';
@ -451,6 +457,7 @@ function item_post(App $a) {
$_REQUEST['origin'] = false; $_REQUEST['origin'] = false;
$wall = 0; $wall = 0;
} }
}
/* /*
* When a photo was uploaded into the message using the (profile wall) ajax * When a photo was uploaded into the message using the (profile wall) ajax

View file

@ -1061,7 +1061,7 @@ class Item
} }
// Create Diaspora signature // Create Diaspora signature
if ($item['origin'] && empty($item['diaspora_signed_text'])) { if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) {
$signed = Diaspora::createCommentSignature($uid, $item); $signed = Diaspora::createCommentSignature($uid, $item);
if (!empty($signed)) { if (!empty($signed)) {
$item['diaspora_signed_text'] = json_encode($signed); $item['diaspora_signed_text'] = json_encode($signed);
@ -1227,13 +1227,10 @@ class Item
Logger::info('The resharer is no forum: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]); Logger::info('The resharer is no forum: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
return; return;
} }
self::update(['post-reason' => self::PR_ANNOUNCEMENT, 'causer-id' => $item['author-id']], ['id' => $parent['id']]);
Logger::info('Set announcement post-reason', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
return;
} }
self::update(['owner-id' => $item['author-id'], 'contact-id' => $cid], ['id' => $parent['id']]); self::update(['post-reason' => self::PR_ANNOUNCEMENT, 'causer-id' => $item['author-id']], ['id' => $parent['id']]);
Logger::info('Change owner of the parent', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'owner-id' => $item['author-id'], 'contact-id' => $cid]); Logger::info('Set announcement post-reason', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
} }
/** /**
@ -1922,7 +1919,7 @@ class Item
// also reset all the privacy bits to the forum default permissions // also reset all the privacy bits to the forum default permissions
$private = ($user['allow_cid'] || $user['allow_gid'] || $user['deny_cid'] || $user['deny_gid']) ? self::PRIVATE : self::PUBLIC; $private = ($user['allow_cid'] || $user['allow_gid'] || $user['deny_cid'] || $user['deny_gid']) ? self::PRIVATE : self::UNLISTED;
$psid = PermissionSet::getIdFromACL( $psid = PermissionSet::getIdFromACL(
$user['uid'], $user['uid'],

View file

@ -20,8 +20,10 @@ use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Model\Verb;
use Friendica\Module\Contact as ModuleContact; use Friendica\Module\Contact as ModuleContact;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
class Network extends BaseModule class Network extends BaseModule
@ -388,7 +390,9 @@ class Network extends BaseModule
if (self::$groupId) { if (self::$groupId) {
$conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$groupId]); $conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$groupId]);
} elseif (self::$forumContactId) { } elseif (self::$forumContactId) {
$conditionFields['contact-id'] = self::$forumContactId; $conditionStrings = DBA::mergeConditions($conditionStrings,
["((`contact-id` = ?) OR EXISTS(SELECT `uri-id` FROM `post-user-view` WHERE `post-user-view`.`parent-uri-id` = `network-thread-view`.`uri-id` AND (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
self::$forumContactId, self::$forumContactId, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
} }
// Currently only the order modes "received" and "commented" are in use // Currently only the order modes "received" and "commented" are in use

View file

@ -533,6 +533,8 @@ class Transmitter
$actor_profile = APContact::getByURL($item['author-link']); $actor_profile = APContact::getByURL($item['author-link']);
} }
$exclusive = false;
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
if ($item['private'] != Item::PRIVATE) { if ($item['private'] != Item::PRIVATE) {
@ -557,6 +559,9 @@ class Transmitter
foreach ($terms as $term) { foreach ($terms as $term) {
$profile = APContact::getByURL($term['url'], false); $profile = APContact::getByURL($term['url'], false);
if (!empty($profile)) { if (!empty($profile)) {
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
$exclusive = true;
}
$data['to'][] = $profile['url']; $data['to'][] = $profile['url'];
} }
} }
@ -612,7 +617,7 @@ class Transmitter
$data['cc'][] = $actor_profile['followers']; $data['cc'][] = $actor_profile['followers'];
} }
} }
} else { } elseif (!$exclusive) {
// Public thread parent post always are directed to the followers // Public thread parent post always are directed to the followers
if (($item['private'] != Item::PRIVATE) && !$forum_mode) { if (($item['private'] != Item::PRIVATE) && !$forum_mode) {
$data['cc'][] = $actor_profile['followers']; $data['cc'][] = $actor_profile['followers'];

View file

@ -283,6 +283,16 @@ class Notifier
} }
Logger::log('Notify ' . $target_item["guid"] .' via PuSH: ' . ($push_notify ? "Yes":"No"), Logger::DEBUG); Logger::log('Notify ' . $target_item["guid"] .' via PuSH: ' . ($push_notify ? "Yes":"No"), Logger::DEBUG);
} elseif ($targets = Tag::getByURIId($target_item['uri-id'], [Tag::EXCLUSIVE_MENTION])) {
$followup = true;
foreach ($targets as $target) {
$cid = Contact::getIdForURL($target['url'], $uid, false);
if ($cid) {
$recipients_followup[] = $cid;
Logger::info('Exclusively delivering', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'url' => $target['url']]);
}
}
} else { } else {
$followup = false; $followup = false;