aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-07-12 17:07:31 -0700
committerzotlabs <mike@macgirvin.com>2017-07-12 17:07:31 -0700
commit6db717a1a09f936f72d5c6c7643b0caa81a40667 (patch)
treec53b6e1eee412187eb31f138ed9ab5ffe1cefa76
parentad9990e1004e58e0049768f5282d86e5e0eb2602 (diff)
downloadvolse-hubzilla-6db717a1a09f936f72d5c6c7643b0caa81a40667.tar.gz
volse-hubzilla-6db717a1a09f936f72d5c6c7643b0caa81a40667.tar.bz2
volse-hubzilla-6db717a1a09f936f72d5c6c7643b0caa81a40667.zip
make websub/PuSH and salmon both use consume_feed() for item storage as there is a lot of duplication of effort and patches applied to one that haven't been applied to the other. This will require an update of addons as well or follow activities may be duplicated
-rw-r--r--include/feedutils.php56
1 files changed, 43 insertions, 13 deletions
diff --git a/include/feedutils.php b/include/feedutils.php
index a725e66e3..fac2a272c 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -516,7 +516,7 @@ function get_atom_elements($feed, $item, &$author) {
// turn Mastodon content warning into a #nsfw hashtag
if($mastodon && $summary) {
- $res['body'] .= "\n\n#nsfw\n";
+ $res['body'] .= "\n\n#ContentWarning\n";
}
@@ -1147,7 +1147,48 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
}
}
- if(! $pmid) {
+ if($pmid) {
+
+ // check comment permissions on the parent
+
+ $r = q("select * from item where parent_mid = '%s' and parent_mid = mid and uid = %d limit 1"
+ dbesc($pmid),
+ intval($importer['channel_id'])
+ );
+ if($r) {
+ $parent_item = $r[0];
+
+ if(intval($parent_item['item_nocomment']) || $parent_item['comment_policy'] === 'none'
+ || ($parent_item['comments_closed'] > NULL_DATE && $parent_item['comments_closed'] < datetime_convert())) {
+ logger('comments disabled for post ' . $parent_item['mid']);
+ continue;
+ }
+
+ $allowed = false;
+
+ if($parent_item) {
+ if($parent_item['owner_xchan'] == $importer['channel_hash'])
+ $allowed = perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments');
+ else
+ $allowed = true;
+
+ if(! $allowed) {
+ logger('Ignoring this comment author.');
+ $status = 202;
+ continue;
+ }
+ }
+ else {
+ if((! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) && (! $importer['system'])) {
+ // @fixme check for and process ostatus autofriend
+ // otherwise
+
+ logger('Ignoring this author.');
+ continue;
+ }
+ }
+ }
+ else {
// immediate parent wasn't found. Turn into a top-level post if permissions allow
// but save the thread_parent in case we need to refer to it later.
@@ -1198,17 +1239,6 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$datarray['author_xchan'] = '';
- if(activity_match($datarray['verb'],ACTIVITY_FOLLOW) && $datarray['obj_type'] === ACTIVITY_OBJ_PERSON) {
- $cb = array('item' => $datarray,'channel' => $importer, 'xchan' => [ 'placeholder' => '' ], 'author' => $author, 'caught' => false);
- call_hooks('follow_from_feed',$cb);
- if($cb['caught']) {
- if($cb['return_code'])
- http_status_exit($cb['return_code']);
-
- continue;
- }
- }
-
if($author['author_link'] != $contact['xchan_url']) {
$name = '';
if($author['full_name']) {