2020-10-21 00:59:03 +00:00
|
|
|
<?php
|
2020-09-23 01:10:11 +00:00
|
|
|
|
|
|
|
namespace Zotlabs\Daemon;
|
|
|
|
|
|
|
|
use Zotlabs\Lib\Activity;
|
|
|
|
use Zotlabs\Lib\ActivityStreams;
|
2020-09-23 04:09:16 +00:00
|
|
|
use Zotlabs\Lib\ASCollection;
|
2020-09-23 01:10:11 +00:00
|
|
|
|
|
|
|
class Convo {
|
|
|
|
|
|
|
|
static public function run($argc,$argv) {
|
|
|
|
|
2020-10-21 00:57:34 +00:00
|
|
|
logger('convo invoked: ' . print_r($argv,true));
|
|
|
|
|
2020-09-23 01:10:11 +00:00
|
|
|
if($argc != 4) {
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = $argv[1];
|
|
|
|
$channel_id = intval($argv[2]);
|
|
|
|
$contact_hash = $argv[3];
|
|
|
|
|
|
|
|
$channel = channelx_by_n($channel_id);
|
|
|
|
if (! $channel) {
|
|
|
|
killme();
|
|
|
|
}
|
2020-09-23 04:09:16 +00:00
|
|
|
|
2020-09-23 01:10:11 +00:00
|
|
|
$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),
|
2020-09-23 04:09:16 +00:00
|
|
|
dbesc($contact_hash)
|
2020-09-23 01:10:11 +00:00
|
|
|
);
|
|
|
|
if (! $r) {
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
|
|
|
|
$contact = array_shift($r);
|
|
|
|
|
|
|
|
$obj = new ASCollection($id, $channel);
|
|
|
|
|
|
|
|
$messages = $obj->get();
|
2020-09-23 04:09:16 +00:00
|
|
|
|
2020-09-23 01:10:11 +00:00
|
|
|
if ($messages) {
|
|
|
|
foreach ($messages as $message) {
|
|
|
|
if (is_string($message)) {
|
|
|
|
$message = Activity::fetch($message,$channel);
|
|
|
|
}
|
2020-10-21 22:37:58 +00:00
|
|
|
// 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, null, true);
|
2020-09-23 01:10:11 +00:00
|
|
|
if ($AS->is_valid() && is_array($AS->obj)) {
|
2020-10-21 22:37:58 +00:00
|
|
|
$item = Activity::decode_note($AS,true);
|
2021-04-06 02:21:28 +00:00
|
|
|
Activity::store($channel,$contact['abook_xchan'],$AS,$item,true,true);
|
2020-09-23 01:10:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|