diff options
author | Max Kostikov <max@kostikov.co> | 2021-01-23 13:07:09 +0000 |
---|---|---|
committer | Max Kostikov <max@kostikov.co> | 2021-01-23 13:07:09 +0000 |
commit | 03910453a98bacd32dc379dc71d99a93d146bae1 (patch) | |
tree | a74e7f4c1b8d117a457ffb646a47f88023d24fd6 /Zotlabs/Daemon/Convo.php | |
parent | 33951dc1e4695bece701b85275d4c282c1936150 (diff) | |
parent | 30962dadbf6c4f4d099fca05a0e7b3261fb6b391 (diff) | |
download | volse-hubzilla-03910453a98bacd32dc379dc71d99a93d146bae1.tar.gz volse-hubzilla-03910453a98bacd32dc379dc71d99a93d146bae1.tar.bz2 volse-hubzilla-03910453a98bacd32dc379dc71d99a93d146bae1.zip |
Merge branch 'dev' into 'dev'
Dev sync
See merge request kostikov/core!3
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); + } + } + } + } +} |