diff options
author | DM42.Net Zap Dev <zapdev@dm42.net> | 2019-09-21 13:30:42 -0400 |
---|---|---|
committer | DM42.Net Zap Dev <zapdev@dm42.net> | 2019-09-21 13:30:42 -0400 |
commit | 6fe4ac241d0dc7710be496a215fc96741856f38a (patch) | |
tree | ad53d8f64830ef22624f9bad7edad19e89666a7e /Zotlabs/Lib/Libzot.php | |
parent | c385b808073fbe9e4422dc0af4c58149e5d6e9d5 (diff) | |
download | volse-hubzilla-6fe4ac241d0dc7710be496a215fc96741856f38a.tar.gz volse-hubzilla-6fe4ac241d0dc7710be496a215fc96741856f38a.tar.bz2 volse-hubzilla-6fe4ac241d0dc7710be496a215fc96741856f38a.zip |
encode/decode comment_policy for Z6
Diffstat (limited to 'Zotlabs/Lib/Libzot.php')
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 2a13744a3..c03749d33 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1223,9 +1223,39 @@ class Libzot { if($private) { $arr['item_private'] = true; } + + if ($arr['mid'] === $arr['parent_mid']) { + if (is_array($AS->obj) && array_key_exists('commentPolicy',$AS->obj)) { + $p = strstr($AS->obj['commentPolicy'],'until='); + if($p !== false) { + $arr['comments_closed'] = datetime_convert('UTC','UTC', substr($p,6)); + $arr['comment_policy'] = trim(str_replace($p,'',$AS->obj['commentPolicy'])); + } + else { + $arr['comment_policy'] = $AS->obj['commentPolicy']; + } + } + } + + /// @FIXME - spoofable if($AS->data['hubloc']) { $arr['item_verified'] = true; + + if (! array_key_exists('comment_policy',$arr)) { + // set comment policy depending on source hub. Unknown or osada is ActivityPub. + // Anything else we'll say is zot - which could have a range of project names + $s = q("select site_project from site where site_url = '%s' limit 1", + dbesc($r[0]['hubloc_url']) + ); + + if ((! $s) || (in_array($s[0]['site_project'],[ '', 'osada' ]))) { + $arr['comment_policy'] = 'authenticated'; + } + else { + $arr['comment_policy'] = 'contacts'; + } + } } if($AS->data['signed_data']) { IConfig::Set($arr,'activitystreams','signed_data',$AS->data['signed_data'],false); |