mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
support binary content
This commit is contained in:
parent
331dac12d3
commit
a14474a135
4 changed files with 42 additions and 12 deletions
|
@ -19,7 +19,7 @@ Groups may be public or private. The initial thread starting post to a group is
|
||||||
|
|
||||||
Comments
|
Comments
|
||||||
|
|
||||||
Zap provides permission control and moderation of comments. By default comments are only accepted from existing connections. This can be changed by the individual. Other sites MAY use zot:commentPolicy (string) as a guide if they do not wish to provide comment abilities where it is known in advance they will be rejected.
|
Zap provides permission control and moderation of comments. By default comments are only accepted from existing connections. This can be changed by the individual. Other sites MAY use zot:commentPolicy (string) as a guide if they do not wish to provide comment abilities where it is known in advance they will be rejected. A Reject/Note activity will be sent if the comment is not permitted. There is currently no response for moderated content, but will likely also be represented by Reject/Note.
|
||||||
|
|
||||||
|
|
||||||
Private Media
|
Private Media
|
||||||
|
@ -29,7 +29,7 @@ Private media MAY be accessed using OCAP or OpenWebAuth.
|
||||||
|
|
||||||
Permission System
|
Permission System
|
||||||
|
|
||||||
The Zot permission system has years of historical use and is different than and the reverse of the typical ActivityPub project. We consider 'Follow' to be an anti-pattern which encourages pseudo anonymous stalking. A Follow activity by a Zap actor typically means the Zap actor will send activities to the recipient. It may also confer other permissions. Accept/Follow provides permission to receive content from the referenced actor.
|
The Zot permission system has years of historical use and is different than and the reverse of the typical ActivityPub project. We consider 'Follow' to be an anti-pattern which encourages pseudo anonymous stalking. A Follow activity by a Zap actor typically means the Zap actor will send activities to the recipient. It may also confer other permissions. Accept/Follow usually provides permission to receive content from the referenced actor, depending on their privacy settings.
|
||||||
|
|
||||||
|
|
||||||
Delivery model
|
Delivery model
|
||||||
|
|
|
@ -849,7 +849,11 @@ class Activity {
|
||||||
$ret['source']['summary'] = $i['summary'];
|
$ret['source']['summary'] = $i['summary'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$ret['mediaType'] = $i['mimetype'];
|
||||||
|
$ret['content'] = $i['body'];
|
||||||
|
}
|
||||||
|
|
||||||
$actor = self::encode_person($i['author'],false);
|
$actor = self::encode_person($i['author'],false);
|
||||||
if ($actor) {
|
if ($actor) {
|
||||||
$ret['actor'] = $actor;
|
$ret['actor'] = $actor;
|
||||||
|
@ -1850,7 +1854,13 @@ class Activity {
|
||||||
$s = [];
|
$s = [];
|
||||||
|
|
||||||
if (is_array($act->obj)) {
|
if (is_array($act->obj)) {
|
||||||
$content = self::get_content($act->obj);
|
$binary = false;
|
||||||
|
if (array_key_exists('mediaType',$act->obj) && $act['mediaType'] !== 'text/html') {
|
||||||
|
$s['mimetype'] = escape_tags($act->obj['mediaType']);
|
||||||
|
$binary = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = self::get_content($act->obj,$binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
// These activities should have been handled separately in the Inbox module and should not be turned into posts
|
// These activities should have been handled separately in the Inbox module and should not be turned into posts
|
||||||
|
@ -1975,8 +1985,14 @@ class Activity {
|
||||||
|
|
||||||
$s['title'] = (($response_activity) ? EMPTY_STR : self::bb_content($content,'name'));
|
$s['title'] = (($response_activity) ? EMPTY_STR : self::bb_content($content,'name'));
|
||||||
$s['summary'] = self::bb_content($content,'summary');
|
$s['summary'] = self::bb_content($content,'summary');
|
||||||
$s['body'] = ((self::bb_content($content,'bbcode') && (! $response_activity)) ? self::bb_content($content,'bbcode') : self::bb_content($content,'content'));
|
|
||||||
|
|
||||||
|
if (array_key_exists('mimetype',$s) && $s['mimetype'] !== 'text/bbcode') {
|
||||||
|
$s['body'] = $content['content'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$s['body'] = ((self::bb_content($content,'bbcode') && (! $response_activity)) ? self::bb_content($content,'bbcode') : self::bb_content($content,'content'));
|
||||||
|
}
|
||||||
|
|
||||||
// handle some of the more widely used of the numerous and varied ways of deleting something
|
// handle some of the more widely used of the numerous and varied ways of deleting something
|
||||||
|
|
||||||
if ($act->type === 'Tombstone') {
|
if ($act->type === 'Tombstone') {
|
||||||
|
@ -2687,7 +2703,7 @@ class Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static function get_content($act) {
|
static function get_content($act,$binary = false) {
|
||||||
|
|
||||||
$content = [];
|
$content = [];
|
||||||
$event = null;
|
$event = null;
|
||||||
|
@ -2696,6 +2712,7 @@ class Activity {
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($act['type'] === 'Event') {
|
if ($act['type'] === 'Event') {
|
||||||
$adjust = false;
|
$adjust = false;
|
||||||
$event = [];
|
$event = [];
|
||||||
|
@ -2718,12 +2735,12 @@ class Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ([ 'name', 'summary', 'content' ] as $a) {
|
foreach ([ 'name', 'summary', 'content' ] as $a) {
|
||||||
if (($x = self::get_textfield($act,$a)) !== false) {
|
if (($x = self::get_textfield($act,$a,$binary)) !== false) {
|
||||||
$content[$a] = $x;
|
$content[$a] = $x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event) {
|
if ($event && ! $binary) {
|
||||||
$event['summary'] = html2plain(purify_html($content['summary']),256);
|
$event['summary'] = html2plain(purify_html($content['summary']),256);
|
||||||
if (! $event['summary']) {
|
if (! $event['summary']) {
|
||||||
if ($content['name']) {
|
if ($content['name']) {
|
||||||
|
@ -2754,15 +2771,15 @@ class Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static function get_textfield($act,$field) {
|
static function get_textfield($act,$field,$binary = false) {
|
||||||
|
|
||||||
$content = false;
|
$content = false;
|
||||||
|
|
||||||
if (array_key_exists($field,$act) && $act[$field])
|
if (array_key_exists($field,$act) && $act[$field])
|
||||||
$content = purify_html($act[$field]);
|
$content = (($binary) ? $act[$field] : purify_html($act[$field]));
|
||||||
elseif (array_key_exists($field . 'Map',$act) && $act[$field . 'Map']) {
|
elseif (array_key_exists($field . 'Map',$act) && $act[$field . 'Map']) {
|
||||||
foreach ($act[$field . 'Map'] as $k => $v) {
|
foreach ($act[$field . 'Map'] as $k => $v) {
|
||||||
$content[escape_tags($k)] = purify_html($v);
|
$content[escape_tags($k)] = (($binary) ? $v : purify_html($v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
|
|
|
@ -1730,6 +1730,8 @@ class Libzot {
|
||||||
if ((! $tag_delivery) && (! $local_public)) {
|
if ((! $tag_delivery) && (! $local_public)) {
|
||||||
$allowed = (perm_is_allowed($channel['channel_id'],$sender,$perm));
|
$allowed = (perm_is_allowed($channel['channel_id'],$sender,$perm));
|
||||||
if ((! $allowed) && $perm === 'post_comments') {
|
if ((! $allowed) && $perm === 'post_comments') {
|
||||||
|
|
||||||
|
|
||||||
$parent = q("select * from item where mid = '%s' and uid = %d limit 1",
|
$parent = q("select * from item where mid = '%s' and uid = %d limit 1",
|
||||||
dbesc($arr['parent_mid']),
|
dbesc($arr['parent_mid']),
|
||||||
intval($channel['channel_id'])
|
intval($channel['channel_id'])
|
||||||
|
@ -1737,6 +1739,10 @@ class Libzot {
|
||||||
if ($parent) {
|
if ($parent) {
|
||||||
$allowed = can_comment_on_post($sender,$parent[0]);
|
$allowed = can_comment_on_post($sender,$parent[0]);
|
||||||
}
|
}
|
||||||
|
if ((! $allowed) && PConfig::Get($channel['channel_id'], 'system','permit_all_mentions') && i_am_mentioned($channel,$arr)) {
|
||||||
|
$allowed = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($request) {
|
if ($request) {
|
||||||
|
|
||||||
|
|
|
@ -558,7 +558,7 @@ function bb_ShareAttributes($match) {
|
||||||
// Bob Smith wrote the following post 2 hours ago
|
// Bob Smith wrote the following post 2 hours ago
|
||||||
|
|
||||||
$fmt = sprintf( t('%1$s wrote the following %2$s %3$s'),
|
$fmt = sprintf( t('%1$s wrote the following %2$s %3$s'),
|
||||||
'<a href="' . (($auth) ? zid($profile) : $profile) . '" >' . $author . '</a>',
|
'<a href="' . (($auth) ? zid($profile) : $profile) . '" ><bdi>' . $author . '</bdi></a>',
|
||||||
'<a href="' . (($auth) ? zid($link) : $link) . '" >' . $type . '</a>',
|
'<a href="' . (($auth) ? zid($link) : $link) . '" >' . $type . '</a>',
|
||||||
$reldate
|
$reldate
|
||||||
);
|
);
|
||||||
|
@ -1349,6 +1349,13 @@ function bbcode($Text, $options = []) {
|
||||||
if (strpos($Text,'[/footer]') !== false) {
|
if (strpos($Text,'[/footer]') !== false) {
|
||||||
$Text = preg_replace("(\[footer\](.*?)\[\/footer\])ism", "<div class=\"wall-item-footer\">$1</div>", $Text);
|
$Text = preg_replace("(\[footer\](.*?)\[\/footer\])ism", "<div class=\"wall-item-footer\">$1</div>", $Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for bdi
|
||||||
|
if (strpos($Text,'[/bdi]') !== false) {
|
||||||
|
$Text = preg_replace("(\[bdi\](.*?)\[\/bdi\])ism", "<bdi>$1</bdi>", $Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check for list text
|
// Check for list text
|
||||||
|
|
||||||
$Text = preg_replace("/<br>\[\*\/\]/ism",'[*/]',$Text);
|
$Text = preg_replace("/<br>\[\*\/\]/ism",'[*/]',$Text);
|
||||||
|
|
Loading…
Reference in a new issue