Merge pull request #8357 from annando/private

Support unlisted public posts
This commit is contained in:
Hypolite Petovan 2020-03-03 01:19:07 -05:00 committed by GitHub
commit dd613cda45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 183 additions and 156 deletions

View file

@ -975,7 +975,8 @@ class BBCode
Contact::getIdForURL($attributes['profile'], 0, true, $default);
$author_contact = Contact::getDetailsByURL($attributes['profile']);
$author_contact['addr'] = ($author_contact['addr'] ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']);
$author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']);
$author_contact['addr'] = ($author_contact['addr'] ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']);
$attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author'];
$attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];

View file

@ -113,6 +113,10 @@ class Item
Activity::FOLLOW,
Activity::ANNOUNCE];
const PUBLIC = 0;
const PRIVATE = 1;
const UNLISTED = 2;
private static $legacy_mode = null;
public static function isLegacyMode()
@ -1542,7 +1546,7 @@ class Item
$item['allow_gid'] = trim($item['allow_gid'] ?? '');
$item['deny_cid'] = trim($item['deny_cid'] ?? '');
$item['deny_gid'] = trim($item['deny_gid'] ?? '');
$item['private'] = intval($item['private'] ?? 0);
$item['private'] = intval($item['private'] ?? self::PUBLIC);
$item['body'] = trim($item['body'] ?? '');
$item['tag'] = trim($item['tag'] ?? '');
$item['attach'] = trim($item['attach'] ?? '');
@ -1738,8 +1742,8 @@ class Item
* The original author commented, but as this is a comment, the permissions
* weren't fixed up so it will still show the comment as private unless we fix it here.
*/
if ((intval($parent['forum_mode']) == 1) && $parent['private']) {
$item['private'] = 0;
if ((intval($parent['forum_mode']) == 1) && ($parent['private'] != self::PUBLIC)) {
$item['private'] = self::PUBLIC;
}
// If its a post that originated here then tag the thread as "mention"
@ -1809,7 +1813,7 @@ class Item
// ACL settings
if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) {
$private = 1;
$private = self::PRIVATE;
} else {
$private = $item['private'];
}
@ -2218,7 +2222,7 @@ class Item
// Only distribute public items from native networks
$condition = ['id' => $itemid, 'uid' => 0,
'network' => array_merge(Protocol::FEDERATED ,['']),
'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => false];
'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => [self::PUBLIC, self::UNLISTED]];
$item = self::selectFirst(self::ITEM_FIELDLIST, $condition);
if (!DBA::isResult($item)) {
return;
@ -2368,7 +2372,7 @@ class Item
}
// Is it a visible public post?
if (!$item["visible"] || $item["deleted"] || $item["moderated"] || $item["private"]) {
if (!$item["visible"] || $item["deleted"] || $item["moderated"] || ($item["private"] == Item::PRIVATE)) {
return;
}
@ -2559,7 +2563,7 @@ class Item
Contact::unmarkForArchival($contact);
}
$update = (!$arr['private'] && ((($arr['author-link'] ?? '') === ($arr['owner-link'] ?? '')) || ($arr["parent-uri"] === $arr["uri"])));
$update = (($arr['private'] != self::PRIVATE) && ((($arr['author-link'] ?? '') === ($arr['owner-link'] ?? '')) || ($arr["parent-uri"] === $arr["uri"])));
// Is it a forum? Then we don't care about the rules from above
if (!$update && in_array($arr["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN]) && ($arr["parent-uri"] === $arr["uri"])) {
@ -2573,7 +2577,7 @@ class Item
['id' => $arr['contact-id']]);
}
// Now do the same for the system wide contacts with uid=0
if (!$arr['private']) {
if ($arr['private'] != self::PRIVATE) {
DBA::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
['id' => $arr['owner-id']]);
@ -2752,7 +2756,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']) ? 1 : 0;
$private = ($user['allow_cid'] || $user['allow_gid'] || $user['deny_cid'] || $user['deny_gid']) ? self::PRIVATE : self::PUBLIC;
$psid = PermissionSet::getIdFromACL(
$user['uid'],
@ -2799,7 +2803,7 @@ class Item
return false;
}
if (($contact['network'] != Protocol::FEED) && $datarray['private']) {
if (($contact['network'] != Protocol::FEED) && ($datarray['private'] == self::PRIVATE)) {
Logger::log('Not public', Logger::DEBUG);
return false;
}
@ -2837,7 +2841,7 @@ class Item
$urlpart = parse_url($datarray2['author-link']);
$datarray["app"] = $urlpart["host"];
} else {
$datarray['private'] = 0;
$datarray['private'] = self::PUBLIC;
}
}
@ -3381,7 +3385,7 @@ class Item
*
* default permissions - anonymous user
*/
$sql = " AND NOT `item`.`private`";
$sql = sprintf(" AND `item`.`private` != %d", self::PRIVATE);
// Profile owner - everything is visible
if ($local_user && ($local_user == $owner_id)) {
@ -3397,12 +3401,12 @@ class Item
$set = PermissionSet::get($owner_id, $remote_user);
if (!empty($set)) {
$sql_set = " OR (`item`.`private` IN (1,2) AND `item`.`wall` AND `item`.`psid` IN (" . implode(',', $set) . "))";
$sql_set = sprintf(" OR (`item`.`private` = %d AND `item`.`wall` AND `item`.`psid` IN (", self::PRIVATE) . implode(',', $set) . "))";
} else {
$sql_set = '';
}
$sql = " AND (NOT `item`.`private`" . $sql_set . ")";
$sql = sprintf(" AND (`item`.`private` != %d", self::PRIVATE) . $sql_set . ")";
}
return $sql;
@ -3504,7 +3508,7 @@ class Item
continue;
}
if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $app->contact['id']) && ($item['network'] == Protocol::DFRN)) {
if ((local_user() == $item['uid']) && ($item['private'] == self::PRIVATE) && ($item['contact-id'] != $app->contact['id']) && ($item['network'] == Protocol::DFRN)) {
$img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]);
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
}
@ -3682,7 +3686,7 @@ class Item
$ret["title"] = DI::l10n()->t('link to source');
}
} elseif (!empty($item['plink']) && ($item['private'] != 1)) {
} elseif (!empty($item['plink']) && ($item['private'] != self::PRIVATE)) {
$ret = [
'href' => $item['plink'],
'orig' => $item['plink'],

View file

@ -82,7 +82,7 @@ class Term
WHERE `thread`.`visible`
AND NOT `thread`.`deleted`
AND NOT `thread`.`moderated`
AND NOT `thread`.`private`
AND `thread`.`private` = ?
AND t.`uid` = 0
AND t.`otype` = ?
AND t.`type` = ?
@ -91,6 +91,7 @@ class Term
GROUP BY `term`
ORDER BY `score` DESC
LIMIT ?",
Item::PUBLIC,
Term::OBJECT_TYPE_POST,
Term::HASHTAG,
$period,
@ -122,11 +123,10 @@ class Term
FROM `term` t
JOIN `item` i ON i.`id` = t.`oid` AND i.`uid` = t.`uid`
JOIN `thread` ON `thread`.`iid` = i.`id`
JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
WHERE `thread`.`visible`
AND NOT `thread`.`deleted`
AND NOT `thread`.`moderated`
AND NOT `thread`.`private`
AND `thread`.`private` = ?
AND `thread`.`wall`
AND `thread`.`origin`
AND t.`otype` = ?
@ -136,6 +136,7 @@ class Term
GROUP BY `term`
ORDER BY `score` DESC
LIMIT ?",
Item::PUBLIC,
Term::OBJECT_TYPE_POST,
Term::HASHTAG,
$period,

View file

@ -280,58 +280,33 @@ class Community extends BaseModule
$r = false;
if (self::$content == 'local') {
$values = [];
$sql_accounttype = '';
$sql_boundaries = '';
if (!is_null(self::$accounttype)) {
$sql_accounttype = " AND `user`.`account-type` = ?";
$values[] = [self::$accounttype];
$condition = ["`wall` AND `origin` AND `private` = ? AND `owner`.`contact-type` = ?", Item::PUBLIC, self::$accounttype];
} else {
$condition = ["`wall` AND `origin` AND `private` = ?", Item::PUBLIC];
}
if (isset($since_id)) {
$sql_boundaries .= " AND `thread`.`commented` > ?";
$values[] = $since_id;
}
if (isset($max_id)) {
$sql_boundaries .= " AND `thread`.`commented` < ?";
$values[] = $max_id;
}
$values[] = $itemspage;
/// @todo Use "unsearchable" here as well (instead of "hidewall")
$r = DBA::p("SELECT `item`.`uri`, `author`.`url` AS `author-link`, `thread`.`commented` FROM `thread`
STRAIGHT_JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin`
$sql_accounttype
$sql_boundaries
ORDER BY `thread`.`commented` DESC
LIMIT ?", $values);
} elseif (self::$content == 'global') {
if (!is_null(self::$accounttype)) {
$condition = ["`uid` = ? AND NOT `author`.`unsearchable` AND NOT `owner`.`unsearchable` AND `owner`.`contact-type` = ?", 0, self::$accounttype];
$condition = ["`uid` = ? AND `private` = ? AND `owner`.`contact-type` = ?", 0, Item::PUBLIC, self::$accounttype];
} else {
$condition = ["`uid` = ? AND NOT `author`.`unsearchable` AND NOT `owner`.`unsearchable`", 0];
$condition = ["`uid` = ? AND `private` = ?", 0, Item::PUBLIC];
}
if (isset($max_id)) {
$condition[0] .= " AND `commented` < ?";
$condition[] = $max_id;
}
if (isset($since_id)) {
$condition[0] .= " AND `commented` > ?";
$condition[] = $since_id;
}
$r = Item::selectThreadForUser(0, ['uri', 'commented'], $condition, ['order' => ['commented' => true], 'limit' => $itemspage]);
} else {
return [];
}
if (isset($max_id)) {
$condition[0] .= " AND `commented` < ?";
$condition[] = $max_id;
}
if (isset($since_id)) {
$condition[0] .= " AND `commented` > ?";
$condition[] = $since_id;
}
$r = Item::selectThreadForUser(0, ['uri', 'commented', 'author-link'], $condition, ['order' => ['commented' => true], 'limit' => $itemspage]);
return DBA::toArray($r);
}
}

View file

@ -54,7 +54,7 @@ class Fetch extends BaseModule
'uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'received', 'app', 'location', 'coord', 'network',
'event-id', 'resource-id', 'author-link', 'author-avatar', 'author-name', 'plink', 'owner-link', 'attach'
];
$condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$condition = ['wall' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Item::selectFirst($fields, $condition);
if (empty($item)) {
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];

View file

@ -49,11 +49,11 @@ class Objects extends BaseModule
// At first we try the original post with that guid
// @TODO: Replace with parameter from router
$item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'origin' => true, 'private' => false]);
$item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'origin' => true, 'private' => [item::PRIVATE, Item::UNLISTED]]);
if (!DBA::isResult($item)) {
// If no original post could be found, it could possibly be a forum post, there we remove the "origin" field.
// @TODO: Replace with parameter from router
$item = Item::selectFirst(['id', 'author-link'], ['guid' => $a->argv[1], 'private' => false]);
$item = Item::selectFirst(['id', 'author-link'], ['guid' => $a->argv[1], 'private' => [item::PRIVATE, Item::UNLISTED]]);
if (!DBA::isResult($item) || !strstr($item['author-link'], DI::baseUrl()->get())) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}

View file

@ -170,12 +170,12 @@ class Post
$conv = $this->getThread();
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
$lock = ((($item['private'] == Item::PRIVATE) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? DI::l10n()->t('Private Message')
: false);
$shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != 1;
$shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE;
$edpost = false;

View file

@ -376,7 +376,7 @@ class Processor
Logger::warning('Unknown parent item.', ['uri' => $item['thr-parent']]);
return false;
}
if ($item_private && !$parent['private']) {
if ($item_private && ($parent['private'] == Item::PRIVATE)) {
Logger::warning('Item is private but the parent is not. Dropping.', ['item-uri' => $item['uri'], 'thr-parent' => $item['thr-parent']]);
return false;
}
@ -443,12 +443,19 @@ class Processor
}
$item['network'] = Protocol::ACTIVITYPUB;
$item['private'] = !in_array(0, $activity['receiver']);
$item['author-link'] = $activity['author'];
$item['author-id'] = Contact::getIdForURL($activity['author'], 0, true);
$item['owner-link'] = $activity['actor'];
$item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
if (in_array(0, $activity['receiver']) && !empty($activity['unlisted'])) {
$item['private'] = Item::UNLISTED;
} elseif (in_array(0, $activity['receiver'])) {
$item['private'] = Item::PUBLIC;
} else {
$item['private'] = Item::PRIVATE;
}
if (!empty($activity['raw'])) {
$item['source'] = $activity['raw'];
$item['protocol'] = Conversation::PARCEL_ACTIVITYPUB;
@ -489,6 +496,10 @@ class Processor
$stored = false;
foreach ($activity['receiver'] as $receiver) {
if ($receiver == -1) {
continue;
}
$item['uid'] = $receiver;
if ($isForum) {
@ -538,7 +549,7 @@ class Processor
}
// Store send a follow request for every reshare - but only when the item had been stored
if ($stored && !$item['private'] && ($item['gravity'] == GRAVITY_PARENT) && ($item['author-link'] != $item['owner-link'])) {
if ($stored && ($item['private'] != Item::PRIVATE) && ($item['gravity'] == GRAVITY_PARENT) && ($item['author-link'] != $item['owner-link'])) {
$author = APContact::getByURL($item['owner-link'], false);
// We send automatic follow requests for reshared messages. (We don't need though for forum posts)
if ($author['type'] != 'Group') {

View file

@ -477,14 +477,15 @@ class Receiver
/**
* Fetch the receiver list from an activity array
*
* @param array $activity
* @param string $actor
* @param array $tags
* @param array $activity
* @param string $actor
* @param array $tags
* @param boolean $fetch_unlisted
*
* @return array with receivers (user id)
* @throws \Exception
*/
private static function getReceivers($activity, $actor, $tags = [])
private static function getReceivers($activity, $actor, $tags = [], $fetch_unlisted = false)
{
$receivers = [];
@ -522,6 +523,11 @@ class Receiver
$receivers['uid:0'] = 0;
}
// Add receiver "-1" for unlisted posts
if ($fetch_unlisted && ($receiver == self::PUBLIC_COLLECTION) && ($element == 'as:cc')) {
$receivers['uid:-1'] = -1;
}
if (($receiver == self::PUBLIC_COLLECTION) && !empty($actor)) {
// This will most likely catch all OStatus connections to Mastodon
$condition = ['alias' => [$actor, Strings::normaliseLink($actor)], 'rel' => [Contact::SHARING, Contact::FRIEND]
@ -993,7 +999,9 @@ class Receiver
}
}
$object_data['receiver'] = self::getReceivers($object, $object_data['actor'], $object_data['tags']);
$object_data['receiver'] = self::getReceivers($object, $object_data['actor'], $object_data['tags'], true);
$object_data['unlisted'] = in_array(-1, $object_data['receiver']);
unset($object_data['receiver']['uid:-1']);
// Common object data:

View file

@ -173,7 +173,7 @@ class Transmitter
$public_contact = Contact::getIdForURL($owner['url'], 0, true);
$condition = ['uid' => 0, 'contact-id' => $public_contact, 'author-id' => $public_contact,
'private' => false, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
'private' => [Item::PUBLIC, Item::UNLISTED], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
'deleted' => false, 'visible' => true, 'moderated' => false];
$count = DBA::count('item', $condition);
@ -401,7 +401,7 @@ class Transmitter
$terms = Term::tagArrayFromItemId($item['id'], [Term::MENTION, Term::IMPLICIT_MENTION]);
if (!$item['private']) {
if ($item['private'] != Item::PRIVATE) {
// Directly mention the original author upon a quoted reshare.
// Else just ensure that the original author receives the reshare.
$announce = self::getAnnounceArray($item);
@ -413,7 +413,12 @@ class Transmitter
$data = array_merge($data, self::fetchPermissionBlockFromConversation($item));
$data['to'][] = ActivityPub::PUBLIC_COLLECTION;
// Check if the item is completely public or unlisted
if ($item['private'] == Item::PUBLIC) {
$data['to'][] = ActivityPub::PUBLIC_COLLECTION;
} else {
$data['cc'][] = ActivityPub::PUBLIC_COLLECTION;
}
foreach ($terms as $term) {
$profile = APContact::getByURL($term['url'], false);
@ -467,13 +472,13 @@ class Transmitter
$data['to'][] = $profile['url'];
} else {
$data['cc'][] = $profile['url'];
if (!$item['private'] && !empty($actor_profile['followers'])) {
if (($item['private'] != Item::PRIVATE) && $item['private'] && !empty($actor_profile['followers'])) {
$data['cc'][] = $actor_profile['followers'];
}
}
} else {
// Public thread parent post always are directed to the followers
if (!$item['private'] && !$forum_mode) {
if (($item['private'] != Item::PRIVATE) && !$forum_mode) {
$data['cc'][] = $actor_profile['followers'];
}
}

View file

@ -182,7 +182,7 @@ class DFRN
// default permissions - anonymous user
$sql_extra = " AND NOT `item`.`private` ";
$sql_extra = sprintf(" AND `item`.`private` != %s ", Item::PRIVATE);
$r = q(
"SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`, `user`.`account-type`
@ -234,7 +234,7 @@ class DFRN
if (!empty($set)) {
$sql_extra = " AND `item`.`psid` IN (" . implode(',', $set) .")";
} else {
$sql_extra = " AND NOT `item`.`private`";
$sql_extra = sprintf(" AND `item`.`private` != %s", Item::PRIVATE);
}
}
@ -332,7 +332,7 @@ class DFRN
if ($public_feed) {
$type = 'html';
// catch any email that's in a public conversation and make sure it doesn't leak
if ($item['private']) {
if ($item['private'] == Item::PRIVATE) {
continue;
}
} else {
@ -955,7 +955,7 @@ class DFRN
$entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET);
}
if ($item['private']) {
if ($item['private'] == Item::PRIVATE) {
$body = Item::fixPrivatePhotos($item['body'], $owner['uid'], $item, $cid);
} else {
$body = $item['body'];
@ -1050,7 +1050,9 @@ class DFRN
}
if ($item['private']) {
XML::addElement($doc, $entry, "dfrn:private", ($item['private'] ? $item['private'] : 1));
// Friendica versions prior to 2020.3 can't handle "unlisted" properly. So we can only transmit public and private
XML::addElement($doc, $entry, "dfrn:private", ($item['private'] == Item::PRIVATE ? Item::PRIVATE : Item::PUBLIC));
XML::addElement($doc, $entry, "dfrn:unlisted", $item['private'] == Item::UNLISTED);
}
if ($item['extid']) {
@ -2404,6 +2406,11 @@ class DFRN
$item["private"] = XML::getFirstNodeValue($xpath, "dfrn:private/text()", $entry);
$unlisted = XML::getFirstNodeValue($xpath, "dfrn:unlisted/text()", $entry);
if (!empty($unlisted) && ($item['private'] != Item::PRIVATE)) {
$item['private'] = Item::UNLISTED;
}
$item["extid"] = XML::getFirstNodeValue($xpath, "dfrn:extid/text()", $entry);
if (XML::getFirstNodeValue($xpath, "dfrn:bookmark/text()", $entry) == "true") {

View file

@ -2211,7 +2211,7 @@ class Diaspora
return false;
}
$item = Item::selectFirst(['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]);
$item = Item::selectFirst(['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
if (!DBA::isResult($item)) {
Logger::log('Item not found, no origin or private: '.$parent_guid);
return false;
@ -2523,7 +2523,7 @@ class Diaspora
// Do we already have this item?
$fields = ['body', 'title', 'attach', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
$item = Item::selectFirst($fields, $condition);
if (DBA::isResult($item)) {
@ -2567,7 +2567,7 @@ class Diaspora
if ($stored) {
$fields = ['body', 'title', 'attach', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
$item = Item::selectFirst($fields, $condition);
if (DBA::isResult($item)) {
@ -2711,7 +2711,7 @@ class Diaspora
$datarray["app"] = $original_item["app"];
$datarray["plink"] = self::plink($author, $guid);
$datarray["private"] = (($public == "false") ? 1 : 0);
$datarray["private"] = (($public == "false") ? Item::PRIVATE : Item::PUBLIC);
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
$datarray["object-type"] = $original_item["object-type"];
@ -2941,7 +2941,7 @@ class Diaspora
}
$datarray["plink"] = self::plink($author, $guid);
$datarray["private"] = (($public == "false") ? 1 : 0);
$datarray["private"] = (($public == "false") ? Item::PRIVATE : Item::PUBLIC);
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
if (isset($address["address"])) {
@ -3245,7 +3245,7 @@ class Diaspora
private static function sendParticipation(array $contact, array $item)
{
// Don't send notifications for private postings
if ($item['private']) {
if ($item['private'] == Item::PRIVATE) {
return;
}
@ -3536,12 +3536,12 @@ class Diaspora
$myaddr = self::myHandle($owner);
$public = ($item["private"] ? "false" : "true");
$public = ($item["private"] == Item::PRIVATE ? "false" : "true");
$created = DateTimeFormat::utc($item['received'], DateTimeFormat::ATOM);
$edited = DateTimeFormat::utc($item["edited"] ?? $item["created"], DateTimeFormat::ATOM);
// Detect a share element and do a reshare
if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
if (($item['private'] != Item::PRIVATE) && ($ret = self::isReshare($item["body"]))) {
$message = ["author" => $myaddr,
"guid" => $item["guid"],
"created_at" => $created,

View file

@ -220,7 +220,7 @@ class Feed {
$header["wall"] = 0;
$header["origin"] = 0;
$header["gravity"] = GRAVITY_PARENT;
$header["private"] = 2;
$header["private"] = Item::PUBLIC;
$header["verb"] = Activity::POST;
$header["object-type"] = Activity\ObjectType::NOTE;

View file

@ -1682,7 +1682,7 @@ class OStatus
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => false,
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => [Item::PUBLIC, Item::UNLISTED],
'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
$repeated_item = Item::selectFirst([], $condition);
if (!DBA::isResult($repeated_item)) {
@ -1827,7 +1827,7 @@ class OStatus
{
$item["id"] = $item["parent"] = 0;
$item["created"] = $item["edited"] = date("c");
$item["private"] = true;
$item["private"] = Item::PRIVATE;
$contact = Probe::uri($item['follow']);
@ -2120,7 +2120,7 @@ class OStatus
]);
}
if (!$item["private"] && !$feed_mode) {
if (($item['private'] != Item::PRIVATE) && !$feed_mode) {
XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:attention",
"href" => "http://activityschema.org/collection/public"]);
XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
@ -2212,8 +2212,8 @@ class OStatus
$authorid = Contact::getIdForURL($owner["url"], 0, true);
$condition = ["`uid` = ? AND `received` > ? AND NOT `deleted`
AND NOT `private` AND `visible` AND `wall` AND `parent-network` IN (?, ?)",
$owner["uid"], $check_date, Protocol::OSTATUS, Protocol::DFRN];
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?)",
$owner["uid"], $check_date, Item::PRIVATE, Protocol::OSTATUS, Protocol::DFRN];
if ($filter === 'comments') {
$condition[0] .= " AND `object-type` = ? ";

View file

@ -122,7 +122,9 @@ class JsonLD
'ostatus' => (object)['@id' => 'http://ostatus.org#', '@type' => '@id'],
'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id'],
'toot' => (object)['@id' => 'http://joinmastodon.org/ns#', '@type' => '@id'],
'litepub' => (object)['@id' => 'http://litepub.social/ns#', '@type' => '@id']];
'litepub' => (object)['@id' => 'http://litepub.social/ns#', '@type' => '@id'],
'sc' => (object)['@id' => 'http://schema.org#', '@type' => '@id'],
'pt' => (object)['@id' => 'https://joinpeertube.org/ns#', '@type' => '@id']];
// Preparation for adding possibly missing content to the context
if (!empty($json['@context']) && is_string($json['@context'])) {

View file

@ -176,7 +176,7 @@ class Delivery
&& empty($parent['allow_gid'])
&& empty($parent['deny_cid'])
&& empty($parent['deny_gid'])
&& !$parent["private"]) {
&& ($parent["private"] != Model\Item::PRIVATE)) {
$public_message = true;
}
}

View file

@ -151,6 +151,8 @@ class Notifier
// If this is a public conversation, notify the feed hub
$public_message = true;
$unlisted = false;
// Do a PuSH
$push_notify = false;
@ -183,6 +185,8 @@ class Notifier
Logger::info('Threaded comment', ['diaspora_delivery' => (int)$diaspora_delivery]);
}
$unlisted = $target_item['private'] == Item::UNLISTED;
// This is IMPORTANT!!!!
// We will only send a "notify owner to relay" or followup message if the referenced post
@ -245,8 +249,7 @@ class Notifier
Logger::info('Followup', ['target' => $target_id, 'guid' => $target_item['guid'], 'to' => $parent['contact-id']]);
//if (!$target_item['private'] && $target_item['wall'] &&
if (!$target_item['private'] &&
if (($target_item['private'] != Item::PRIVATE) &&
(strlen($target_item['allow_cid'].$target_item['allow_gid'].
$target_item['deny_cid'].$target_item['deny_gid']) == 0))
$push_notify = true;
@ -410,7 +413,7 @@ class Notifier
if ($public_message && !in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION]) && !$followup) {
$relay_list = [];
if ($diaspora_delivery) {
if ($diaspora_delivery && !$unlisted) {
$batch_delivery = true;
$relay_list_stmt = DBA::p(

View file

@ -657,11 +657,11 @@ class OnePoll
$datarray['owner-avatar'] = $contact['photo'];
if ($datarray['parent-uri'] === $datarray['uri']) {
$datarray['private'] = 1;
$datarray['private'] = Item::PRIVATE;
}
if (!DI::pConfig()->get($importer_uid, 'system', 'allow_public_email_replies')) {
$datarray['private'] = 1;
$datarray['private'] = Item::PRIVATE;
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}