1
0
Fork 0

Merge pull request #11230 from annando/account-type

Use "account-type" instead of "page-flags"
This commit is contained in:
Hypolite Petovan 2022-02-09 22:23:55 -05:00 committed by GitHub
commit 1b73e4d267
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 105 additions and 63 deletions

View file

@ -512,13 +512,13 @@ class Transmitter
* @param array $item Item array
* @param boolean $blindcopy addressing via "bcc" or "cc"?
* @param integer $last_id Last item id for adding receivers
* @param boolean $forum_mode "true" means that we are sending content to a forum
* @param boolean $forum_post "true" means that we are sending content to a forum
*
* @return array with permission data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
private static function createPermissionBlockForItem($item, $blindcopy, $last_id = 0, $forum_mode = false)
private static function createPermissionBlockForItem($item, $blindcopy, $last_id = 0, $forum_post = false)
{
if ($last_id == 0) {
$last_id = $item['id'];
@ -645,7 +645,7 @@ class Transmitter
// Public thread parent post always are directed to the followers.
// This mustn't be done by posts that are directed to forum servers via the exclusive mention.
// But possibly in that case we could add the "followers" collection of the forum to the message.
if (($item['private'] != Item::PRIVATE) && !$forum_mode) {
if (($item['private'] != Item::PRIVATE) && !$forum_post) {
$data['cc'][] = $actor_profile['followers'];
}
}
@ -815,14 +815,14 @@ class Transmitter
* @param integer $uid User ID
* @param boolean $personal fetch personal inboxes
* @param integer $last_id Last item id for adding receivers
* @param boolean $forum_mode "true" means that we are sending content to a forum
* @param boolean $forum_post "true" means that we are sending content to a forum
* @return array with inboxes
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function fetchTargetInboxes($item, $uid, $personal = false, $last_id = 0, $forum_mode = false)
public static function fetchTargetInboxes($item, $uid, $personal = false, $last_id = 0, $forum_post = false)
{
$permissions = self::createPermissionBlockForItem($item, true, $last_id, $forum_mode);
$permissions = self::createPermissionBlockForItem($item, true, $last_id, $forum_post);
if (empty($permissions)) {
return [];
}

View file

@ -925,9 +925,9 @@ class DFRN
foreach ($mentioned as $mention) {
$condition = ['uid' => $owner["uid"], 'nurl' => Strings::normaliseLink($mention)];
$contact = DBA::selectFirst('contact', ['forum', 'prv'], $condition);
$contact = DBA::selectFirst('contact', ['contact-type'], $condition);
if (DBA::isResult($contact) && ($contact["forum"] || $contact["prv"])) {
if (DBA::isResult($contact) && ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
XML::addElement(
$doc,
$entry,
@ -1547,7 +1547,7 @@ class DFRN
if ($item["thr-parent"] != $item["uri"]) {
$community = false;
if ($importer["page-flags"] == User::PAGE_FLAGS_COMMUNITY || $importer["page-flags"] == User::PAGE_FLAGS_PRVGROUP) {
if ($importer['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
$sql_extra = "";
$community = true;
Logger::notice("possible community action");
@ -2381,14 +2381,11 @@ class DFRN
return false;
}
$user = DBA::selectFirst('user', ['page-flags', 'nickname'], ['uid' => $uid]);
$user = DBA::selectFirst('user', ['account-type', 'nickname'], ['uid' => $uid]);
if (!DBA::isResult($user)) {
return false;
}
$community_page = ($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY);
$prvgroup = ($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP);
$link = Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname']);
/*
@ -2411,7 +2408,7 @@ class DFRN
return false;
}
return $community_page || $prvgroup;
return ($user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY);
}
/**

View file

@ -859,7 +859,7 @@ class Diaspora
// Yes, then it is fine.
return true;
// Is it a post to a community?
} elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
} elseif (($contact["rel"] == Contact::FOLLOWER) && ($importer['account-type'] == User::ACCOUNT_TYPE_COMMUNITY)) {
// That's good
return true;
// Is the message a global user or a comment?