mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:35:30 +00:00
ocap stuff
This commit is contained in:
parent
94c1c89396
commit
a8e68c2e9e
6 changed files with 53 additions and 11 deletions
|
@ -822,11 +822,15 @@ class Activity {
|
|||
/* Add mentions only if the targets are individuals */
|
||||
$m = self::map_acl($i,(($i['allow_gid']) ? false : true));
|
||||
$ret['tag'] = (($ret['tag']) ? array_merge($ret['tag'],$m) : $m);
|
||||
$ret['to'] = [ $reply_url ];
|
||||
if (is_array($m) && $m && ! $ret['to']) {
|
||||
$ret['to'] = [];
|
||||
if ($reply_url) {
|
||||
$ret['to'] = [ $reply_url ];
|
||||
}
|
||||
if (is_array($m) && $m) {
|
||||
if (! $ret['to']) {
|
||||
$ret['to'] = [];
|
||||
}
|
||||
foreach ($m as $ma) {
|
||||
if (is_array($ma) && $ma['type'] === 'Mention') {
|
||||
if (is_array($ma) && $ma['type'] === 'Mention' && $ma['href']) {
|
||||
$ret['to'][] = $ma['href'];
|
||||
}
|
||||
}
|
||||
|
@ -866,6 +870,9 @@ class Activity {
|
|||
$list = [];
|
||||
|
||||
foreach ($i['term'] as $t) {
|
||||
if (! $t['url']) {
|
||||
continue;
|
||||
}
|
||||
if ($t['ttype'] == TERM_MENTION) {
|
||||
$url = self::lookup_term_url($t['url']);
|
||||
$list[] = (($url) ? $url : $t['url']);
|
||||
|
|
|
@ -6,7 +6,7 @@ use Zotlabs\Lib\ActivityStreams;
|
|||
use Zotlabs\Lib\Activity;
|
||||
use Zotlabs\Lib\Queue;
|
||||
use Zotlabs\Daemon\Master;
|
||||
|
||||
use Zotlabs\Lib\IConfig;
|
||||
|
||||
class ActivityPub {
|
||||
|
||||
|
@ -59,11 +59,24 @@ class ActivityPub {
|
|||
$jmsg = $signed_msg;
|
||||
}
|
||||
else {
|
||||
|
||||
$ti = Activity::encode_activity($target_item, true);
|
||||
if (! $ti) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target_item['mid'] !== $target_item['parent_mid']) {
|
||||
$token = IConfig::get($target_item['id'],'ocap','relay');
|
||||
if ($token) {
|
||||
if (defined('USE_BEARCAPS')) {
|
||||
$ti['id'] = 'bear:?u=' . $ti['id'] . '&t=' . $token;
|
||||
}
|
||||
else {
|
||||
$ti['id'] = $ti['id'] . '?token=' . $token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$msg = array_merge(['@context' => [
|
||||
ACTIVITYSTREAMS_JSONLD_REV,
|
||||
'https://w3id.org/security/v1',
|
||||
|
|
|
@ -23,7 +23,7 @@ class Activity extends Controller {
|
|||
$bear = ZlibActivity::token_from_request();
|
||||
if ($bear) {
|
||||
logger('bear: ' . $bear, LOGGER_DEBUG);
|
||||
$t = q("select item.uid, iconfig.v from iconfig left join item on iid = item.id where cat = 'ocaps' and item.uuid = '%s'",
|
||||
$t = q("select item.uid, iconfig.v from iconfig left join item on iid = item.id where cat = 'ocap' and item.uuid = '%s'",
|
||||
dbesc($item_id)
|
||||
);
|
||||
if ($t) {
|
||||
|
|
|
@ -1160,6 +1160,8 @@ class Item extends Controller {
|
|||
$plink = z_root() . '/item/' . $uuid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$datarray['aid'] = $channel['channel_account_id'];
|
||||
$datarray['uid'] = $profile_uid;
|
||||
$datarray['uuid'] = $uuid;
|
||||
|
@ -1233,8 +1235,14 @@ class Item extends Controller {
|
|||
if(! empty_acl($datarray))
|
||||
$datarray['public_policy'] = '';
|
||||
|
||||
if($iconfig)
|
||||
if ($iconfig) {
|
||||
$datarray['iconfig'] = $iconfig;
|
||||
}
|
||||
if ($private) {
|
||||
IConfig::set($datarray,'ocap','relay',new_token());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// preview mode - prepare the body for display and send it via json
|
||||
|
||||
|
|
4
boot.php
4
boot.php
|
@ -48,7 +48,7 @@ require_once('include/items.php');
|
|||
|
||||
|
||||
|
||||
define ( 'STD_VERSION', '19.9.27' );
|
||||
define ( 'STD_VERSION', '19.9.30' );
|
||||
define ( 'ZOT_REVISION', '6.0' );
|
||||
|
||||
define ( 'DB_UPDATE_VERSION', 1236 );
|
||||
|
@ -70,6 +70,8 @@ define ( 'EMPTY_STR', '' );
|
|||
define ( 'ATOM_TIME', 'Y-m-d\\TH:i:s\\Z' ); // aka ISO 8601 "Zulu"
|
||||
define ( 'TEMPLATE_BUILD_PATH', 'store/[data]/smarty3' );
|
||||
|
||||
//define ( 'USE_BEARCAPS', true);
|
||||
|
||||
define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // A directory client
|
||||
define ( 'DIRECTORY_MODE_PRIMARY', 0x0001); // There can only be *one* primary directory server in a directory_realm.
|
||||
define ( 'DIRECTORY_MODE_SECONDARY', 0x0002); // All other mirror directory servers
|
||||
|
|
|
@ -593,8 +593,20 @@ function photo_new_resource() {
|
|||
}
|
||||
|
||||
|
||||
function new_token() {
|
||||
return random_string(mt_rand(48,64));
|
||||
// provide psuedo random token (string) consisting entirely of US-ASCII letters/numbers
|
||||
// and with possibly variable length
|
||||
|
||||
function new_token($minlen = 36,$maxlen = 48) {
|
||||
|
||||
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
||||
$str = EMPTY_STR;
|
||||
|
||||
$len = (($minlen === $maxlen) ? $minlen : mt_rand($minlen,$maxlen));
|
||||
|
||||
for($a = 0; $a < $len; $a ++) {
|
||||
$str .= $chars[mt_rand(0,62)];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue