mirror of
https://github.com/friendica/friendica
synced 2024-11-10 09:02:53 +00:00
Merge pull request #10372 from annando/forum-handling
Improved forum handling
This commit is contained in:
commit
49b9505972
5 changed files with 45 additions and 22 deletions
33
mod/item.php
33
mod/item.php
|
@ -40,6 +40,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\APContact;
|
||||
use Friendica\Model\Attach;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Conversation;
|
||||
|
@ -435,21 +436,27 @@ function item_post(App $a) {
|
|||
$original_contact_id = $contact_id;
|
||||
|
||||
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
|
||||
$private = $private_forum;
|
||||
// we tagged a forum in a top level post. Now we change the post
|
||||
$private = $private_forum ? Item::PRIVATE : Item::UNLISTED;
|
||||
|
||||
$str_group_allow = '';
|
||||
$str_contact_deny = '';
|
||||
$str_group_deny = '';
|
||||
if ($private_forum) {
|
||||
$str_contact_allow = '<' . $private_id . '>';
|
||||
} else {
|
||||
$str_contact_allow = '';
|
||||
if ($only_to_forum) {
|
||||
$postopts = '';
|
||||
}
|
||||
|
||||
if ($private_forum || !APContact::getByURL($forum_contact['url'])) {
|
||||
$str_group_allow = '';
|
||||
$str_contact_deny = '';
|
||||
$str_group_deny = '';
|
||||
if ($private_forum) {
|
||||
$str_contact_allow = '<' . $private_id . '>';
|
||||
} else {
|
||||
$str_contact_allow = '';
|
||||
}
|
||||
$contact_id = $private_id;
|
||||
$contact_record = $forum_contact;
|
||||
$_REQUEST['origin'] = false;
|
||||
$wall = 0;
|
||||
}
|
||||
$contact_id = $private_id;
|
||||
$contact_record = $forum_contact;
|
||||
$_REQUEST['origin'] = false;
|
||||
$wall = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1061,7 +1061,7 @@ class Item
|
|||
}
|
||||
|
||||
// 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);
|
||||
if (!empty($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']]);
|
||||
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']]);
|
||||
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]);
|
||||
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']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1922,7 +1919,7 @@ class Item
|
|||
|
||||
// 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(
|
||||
$user['uid'],
|
||||
|
|
|
@ -20,8 +20,10 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Model\Verb;
|
||||
use Friendica\Module\Contact as ModuleContact;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
class Network extends BaseModule
|
||||
|
@ -388,7 +390,9 @@ class Network extends BaseModule
|
|||
if (self::$groupId) {
|
||||
$conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$groupId]);
|
||||
} 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
|
||||
|
|
|
@ -533,6 +533,8 @@ class Transmitter
|
|||
$actor_profile = APContact::getByURL($item['author-link']);
|
||||
}
|
||||
|
||||
$exclusive = false;
|
||||
|
||||
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
|
||||
|
||||
if ($item['private'] != Item::PRIVATE) {
|
||||
|
@ -557,6 +559,9 @@ class Transmitter
|
|||
foreach ($terms as $term) {
|
||||
$profile = APContact::getByURL($term['url'], false);
|
||||
if (!empty($profile)) {
|
||||
if ($term['type'] == Tag::EXCLUSIVE_MENTION) {
|
||||
$exclusive = true;
|
||||
}
|
||||
$data['to'][] = $profile['url'];
|
||||
}
|
||||
}
|
||||
|
@ -612,7 +617,7 @@ class Transmitter
|
|||
$data['cc'][] = $actor_profile['followers'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} elseif (!$exclusive) {
|
||||
// Public thread parent post always are directed to the followers
|
||||
if (($item['private'] != Item::PRIVATE) && !$forum_mode) {
|
||||
$data['cc'][] = $actor_profile['followers'];
|
||||
|
|
|
@ -283,6 +283,16 @@ class Notifier
|
|||
}
|
||||
|
||||
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 {
|
||||
$followup = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue