diff options
author | Mario <mario@mariovavti.com> | 2021-01-22 10:06:50 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-01-22 10:06:50 +0000 |
commit | 93ac3c985fd35a9826c5421360da368ff07dd315 (patch) | |
tree | 1a9c88970ba16e531490553895ab40efa971e706 /Zotlabs/Daemon/Convo.php | |
parent | fe97b63e0b227b2702f661490424b1e12c06f73a (diff) | |
download | volse-hubzilla-93ac3c985fd35a9826c5421360da368ff07dd315.tar.gz volse-hubzilla-93ac3c985fd35a9826c5421360da368ff07dd315.tar.bz2 volse-hubzilla-93ac3c985fd35a9826c5421360da368ff07dd315.zip |
implement externals via zot6 and zotfeed - part 1
Diffstat (limited to 'Zotlabs/Daemon/Convo.php')
-rw-r--r-- | Zotlabs/Daemon/Convo.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Zotlabs/Daemon/Convo.php b/Zotlabs/Daemon/Convo.php new file mode 100644 index 000000000..f7478d778 --- /dev/null +++ b/Zotlabs/Daemon/Convo.php @@ -0,0 +1,58 @@ +<?php + +namespace Zotlabs\Daemon; + +use Zotlabs\Lib\Activity; +use Zotlabs\Lib\ActivityStreams; +use Zotlabs\Lib\ASCollection; + +class Convo { + + static public function run($argc, $argv) { + + logger('convo invoked: ' . print_r($argv, true)); + + if ($argc != 4) { + return; + } + + $id = $argv[1]; + $channel_id = intval($argv[2]); + $contact_hash = $argv[3]; + + $channel = channelx_by_n($channel_id); + if (!$channel) { + return; + } + + $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash + WHERE abook_channel = %d and abook_xchan = '%s' LIMIT 1", + intval($channel_id), + dbesc($contact_hash) + ); + if (!$r) { + return; + } + + $contact = array_shift($r); + + $obj = new ASCollection($id, $channel); + + $messages = $obj->get(); + + if ($messages) { + foreach ($messages as $message) { + if (is_string($message)) { + $message = Activity::fetch($message, $channel); + } + // set client flag because comments will probably just be objects and not full blown activities + // and that lets us use implied_create + $AS = new ActivityStreams($message); + if ($AS->is_valid() && is_array($AS->obj)) { + $item = Activity::decode_note($AS, true); + Activity::store($channel, $contact['abook_xchan'], $AS, $item); + } + } + } + } +} |