Merge branch 'dev' of codeberg.org:streams/streams into dev

This commit is contained in:
Mike Macgirvin 2023-12-06 10:28:52 +11:00
commit f0583b510f
12 changed files with 311 additions and 111 deletions

View file

@ -5,6 +5,7 @@ namespace Code\ActivityStreams;
class ASObject
{
public $string;
public $ldContext;
public $id;
public $type;
@ -76,13 +77,18 @@ class ASObject
public function __construct($input = null, $strict = false)
{
if (isset($input) && is_array($input)) {
foreach ($input as $key => $value) {
$key = ($key === '@context') ? 'ldcontext' : $key;
if ($strict && !property_exists($this, $key)) {
throw new UnhandledElementException("Unhandled element: $key");
if (isset($input)) {
if (is_string($input)) {
$this->string = $input;
}
elseif(is_array($input)) {
foreach ($input as $key => $value) {
$key = ($key === '@context') ? 'ldcontext' : $key;
if ($strict && !property_exists($this, $key)) {
throw new UnhandledElementException("Unhandled element: $key");
}
$this->{$key} = $value;
}
$this->{$key} = $value;
}
}
return $this;
@ -795,11 +801,19 @@ class ASObject
public function toArray()
{
if ($this->string) {
return $this->string;
}
$returnValue = [];
foreach ((array) $this as $key => $value) {
if (isset($value)) {
$key = ($key === 'ldcontext') ? '@context' : $key;
$returnValue[$key] = $value;
if ($value instanceof ASObject || $value instanceof Link) {
$returnValue[$key] = $value->toArray();
}
else {
$returnValue[$key] = $value;
}
}
}
return $returnValue;

View file

@ -0,0 +1,87 @@
<?php
namespace Code\ActivityStreams;
class AssertionMethod extends ASObject
{
public $id;
public $type;
public $controller;
public $publicKeyMultibase;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
* @return AssertionMethod
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return mixed
*/
public function getType()
{
return $this->type;
}
/**
* @param mixed $type
* @return AssertionMethod
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return mixed
*/
public function getController()
{
return $this->controller;
}
/**
* @param mixed $controller
* @return AssertionMethod
*/
public function setController($controller)
{
$this->controller = $controller;
return $this;
}
/**
* @return mixed
*/
public function getPublicKeyMultibase()
{
return $this->publicKeyMultibase;
}
/**
* @param mixed $publicKeyMultibase
* @return AssertionMethod
*/
public function setPublicKeyMultibase($publicKeyMultibase)
{
$this->publicKeyMultibase = $publicKeyMultibase;
return $this;
}
}

View file

@ -16,13 +16,18 @@ class Link
public function __construct($input = null, $strict = false)
{
if (isset($input) && is_array($input)) {
foreach ($input as $key => $value) {
$key = ($key === '@context') ? 'ldcontext' : $key;
if ($strict && !property_exists($this, $key)) {
throw new UnhandledElementException("Unhandled element: $key");
if (isset($input)) {
if (is_string($input)) {
$this->string = $input;
}
elseif(is_array($input)) {
foreach ($input as $key => $value) {
$key = ($key === '@context') ? 'ldcontext' : $key;
if ($strict && !property_exists($this, $key)) {
throw new UnhandledElementException("Unhandled element: $key");
}
$this->{$key} = $value;
}
$this->{$key} = $value;
}
}
return $this;
@ -174,11 +179,19 @@ class Link
public function toArray()
{
if ($this->string) {
return $this->string;
}
$returnValue = [];
foreach ((array) $this as $key => $value) {
if (isset($value)) {
$key = ($key === 'ldcontext') ? '@context' : $key;
$returnValue[$key] = $value;
if ($value instanceof ASObject || $value instanceof Link) {
$returnValue[$key] = $value->toArray();
}
else {
$returnValue[$key] = $value;
}
}
}
return $returnValue;

View file

@ -26,5 +26,43 @@ class PublicKey extends ASObject
return $this;
}
/**
* @return mixed
*/
public function getSignatureAlgorithm()
{
return $this->signatureAlgorithm;
}
/**
* @param mixed $signatureAlgorithm
* @return PublicKey
*/
public function setSignatureAlgorithm($signatureAlgorithm)
{
$this->signatureAlgorithm = $signatureAlgorithm;
return $this;
}
/**
* @return mixed
*/
public function getPublicKeyPem()
{
return $this->publicKeyPem;
}
/**
* @param mixed $publicKeyPem
* @return PublicKey
*/
public function setPublicKeyPem($publicKeyPem)
{
$this->publicKeyPem = $publicKeyPem;
return $this;
}
}

View file

@ -60,7 +60,7 @@ require_once('include/bbcode.php');
*
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
*
* ZOT
* Nomad
* permissions_create abook_id
* permissions_accept abook_id
* permissions_reject abook_id
@ -74,7 +74,6 @@ require_once('include/bbcode.php');
* single_mail mail_id (deliver to a singleton network from the appropriate clone)
* location channel_id
* request channel_id xchan_hash message_id
* rating xlink_id
* keychange channel_id
*
*/

View file

@ -1216,7 +1216,7 @@ class Activity
$activity['inReplyTo'] = $item['thr_parent'];
$cnv = get_iconfig($item['parent'], 'activitypub', 'context');
if (!$cnv) {
$cnv = $activity['parent_mid'];
$cnv = $item['parent_mid'];
}
}
if (!isset($cnv)) {
@ -1709,6 +1709,13 @@ class Activity
'publicKeyPem' => $p['xchan_pubkey']
];
$ret['assertionMethod'] = [
'id' => $current_url . '?operation=ed25519key',
'type' => 'Multikey',
'controller' => $current_url,
'publicKeyMultibase' => (new Multibase())->publicKey($c['channel_epubkey'])
];
$ret['manuallyApprovesFollowers'] = !$auto_follow;
if ($ret['type'] === 'Group') {
$ret['capabilities'] = ['acceptsJoins' => true];
@ -4828,8 +4835,9 @@ class Activity
{
return ['@context' => [
ACTIVITYSTREAMS_JSONLD_REV,
'https://w3id.org/security/v1',
// 'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/v1',
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/multikey/v1',
// 'https://w3id.org/security/data-integrity/v1',
self::ap_schema($contextType)
]];
@ -4850,7 +4858,7 @@ class Activity
'oauthRegistrationEndpoint' => 'litepub:oauthRegistrationEndpoint',
'sensitive' => 'as:sensitive',
'movedTo' => 'as:movedTo',
'alsoKnownAs' => 'as:alsoKnownAs',
// 'alsoKnownAs' => 'as:alsoKnownAs',
'EmojiReact' => 'as:EmojiReact',
'discoverable' => 'toot:discoverable',
'indexable' => 'toot:indexable',

View file

@ -548,6 +548,9 @@ class Linkinfo extends Controller
case "og:image":
$siteinfo["image"] = $attr["content"];
break;
case "og:image:alt":
$siteinfo["image_alt"] = $attr["content"];
break;
case "og:title":
$siteinfo["title"] = $attr["content"];
break;
@ -568,6 +571,7 @@ class Linkinfo extends Controller
}
$src = self::completeurl($attr["src"], $url);
$alt = $attr["alt"];
$photodata = @getimagesize($src);
if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
@ -581,7 +585,9 @@ class Linkinfo extends Controller
}
$siteinfo["images"][] = ["src" => $src,
"width" => $photodata[0],
"height" => $photodata[1]];
"height" => $photodata[1],
"alt" => ($alt ?? "")
];
}
}
} else {
@ -589,12 +595,17 @@ class Linkinfo extends Controller
unset($siteinfo["image"]);
$alt = $siteinfo["image_alt"];
unset($siteinfo["image_alt"]);
$photodata = @getimagesize($src);
if (($photodata) && ($photodata[0] > 10) and ($photodata[1] > 10)) {
$siteinfo["images"][] = ["src" => $src,
"width" => $photodata[0],
"height" => $photodata[1]];
"height" => $photodata[1],
"alt" => ($alt ?? '')
];
}
}

30
Code/Update/_1273.php Normal file
View file

@ -0,0 +1,30 @@
<?php
namespace Code\Update;
class _1273
{
public function run()
{
if (ACTIVE_DBTYPE != DBTYPE_POSTGRES) {
q("START TRANSACTION");
$r = q("ALTER TABLE session MODIFY COLUMN sess_data MEDIUMTEXT NOT NULL");
if ($r) {
q("COMMIT");
return UPDATE_SUCCESS;
} else {
q("ROLLBACK");
return UPDATE_FAILED;
}
}
}
public function verify()
{
return true;
}
}

View file

@ -26,7 +26,7 @@ use Code\Lib\Url;
*/
const REPOSITORY_ID = 'streams';
const DB_UPDATE_VERSION = 1272;
const DB_UPDATE_VERSION = 1273;
const PROJECT_BASE = __DIR__;
const ACTIVITYPUB_ENABLED = true;
const NOMAD_PROTOCOL_VERSION = '12.0';

View file

@ -1039,7 +1039,7 @@ CREATE TABLE IF NOT EXISTS `register` (
CREATE TABLE IF NOT EXISTS `session` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`sid` varchar(255) NOT NULL DEFAULT '',
`sess_data` text NOT NULL,
`sess_data` mediumtext NOT NULL,
`expire` bigint unsigned NOT NULL DEFAULT 0 ,
PRIMARY KEY (`id`),
KEY `sid` (`sid`(191)),

View file

@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 23.11.28\n"
"Project-Id-Version: 23.12.04\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-27 10:24-0800\n"
"POT-Creation-Date: 2023-12-04 01:19-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -110,13 +110,13 @@ msgstr ""
msgid "Your service plan only allows %d channels."
msgstr ""
#: Code/Import/Friendica.php:191 Code/Lib/Channel.php:512
#: Code/Import/Friendica.php:191 Code/Lib/Channel.php:502
msgid "Default Profile"
msgstr ""
#: Code/Import/Friendica.php:237 Code/Import/Friendica.php:238
#: Code/Import/Friendica.php:246 Code/Lib/Channel.php:561
#: Code/Lib/Channel.php:563 Code/Module/Settings/Channel.php:621
#: Code/Import/Friendica.php:246 Code/Lib/Channel.php:551
#: Code/Lib/Channel.php:553 Code/Module/Settings/Channel.php:621
#: Code/Module/Settings/Channel.php:624 Code/Module/Settings/Channel.php:625
#: Code/Module/Settings/Profile_edit.php:881 Code/Module/Affinity.php:66
#: Code/Module/Connedit.php:697 Code/Widget/Affinity.php:31
@ -847,7 +847,7 @@ msgstr ""
msgid "Probe"
msgstr ""
#: Code/Lib/Apps.php:438 Code/Lib/Libprofile.php:753 Code/Lib/Activity.php:3073
#: Code/Lib/Apps.php:438 Code/Lib/Activity.php:3080 Code/Lib/Libprofile.php:753
#: Code/Module/Profperm.php:131
msgid "Profile"
msgstr ""
@ -1012,7 +1012,7 @@ msgstr ""
msgid "Unpin from navbar"
msgstr ""
#: Code/Lib/Apps.php:1260 Code/Lib/Apps.php:1351 Code/Lib/Activity.php:2303
#: Code/Lib/Apps.php:1260 Code/Lib/Apps.php:1351 Code/Lib/Activity.php:2310
#: Code/Module/Cdav.php:876 Code/Module/Cdav.php:877 Code/Module/Cdav.php:883
#: Code/Module/Embedphotos.php:339 Code/Module/Photos.php:854
#: Code/Module/Photos.php:1322 Code/Storage/Browser.php:182
@ -1082,6 +1082,65 @@ msgstr ""
msgid "Account '%s' deleted"
msgstr ""
#: Code/Lib/Activity.php:473
msgid "Quoted post"
msgstr ""
#: Code/Lib/Activity.php:3078
msgid "Activity"
msgstr ""
#: Code/Lib/Activity.php:3084
#, php-format
msgid "Likes %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3087
#, php-format
msgid "Doesn't like %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3090
#, php-format
msgid "Flagged %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3093
#, php-format
msgid "Blocked %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3101
#, php-format
msgid "Will attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3104
#, php-format
msgid "Will not attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3107
#, php-format
msgid "May attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3110
#, php-format
msgid "May not attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3115
#, php-format
msgid "&#x1f4e2; Repeated %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3712 include/misc.php:1668 include/misc.php:3129
#: include/items.php:3006
#, php-format
msgid "%1$s (%2$s)"
msgstr ""
#: Code/Lib/Navbar.php:104
msgid "Remote authentication"
msgstr ""
@ -1244,55 +1303,55 @@ msgstr ""
msgid "request-header: "
msgstr ""
#: Code/Lib/Channel.php:55
#: Code/Lib/Channel.php:45
msgid "Empty name"
msgstr ""
#: Code/Lib/Channel.php:59
#: Code/Lib/Channel.php:49
msgid "Name too long"
msgstr ""
#: Code/Lib/Channel.php:287
#: Code/Lib/Channel.php:277
msgid "No account identifier"
msgstr ""
#: Code/Lib/Channel.php:299
#: Code/Lib/Channel.php:289
msgid "Nickname is required."
msgstr ""
#: Code/Lib/Channel.php:313 Code/Lib/Channel.php:783
#: Code/Lib/Channel.php:303 Code/Lib/Channel.php:777
#: Code/Module/Changeaddr.php:72
msgid "Reserved nickname. Please choose another."
msgstr ""
#: Code/Lib/Channel.php:318 Code/Lib/Channel.php:788
#: Code/Lib/Channel.php:308 Code/Lib/Channel.php:782
#: Code/Module/Changeaddr.php:77
msgid ""
"Nickname has unsupported characters or is already being used on this site."
msgstr ""
#: Code/Lib/Channel.php:402
#: Code/Lib/Channel.php:392
msgid "Unable to retrieve created identity"
msgstr ""
#: Code/Lib/Channel.php:709 Code/Lib/Channel.php:807
#: Code/Lib/Channel.php:703 Code/Lib/Channel.php:801
msgid "Unable to retrieve modified identity"
msgstr ""
#: Code/Lib/Channel.php:1868 Code/Module/Cover_photo.php:289
#: Code/Lib/Channel.php:1862 Code/Module/Cover_photo.php:289
#: Code/Module/Cover_photo.php:291 Code/Widget/Cover_photo.php:92
msgid "cover photo"
msgstr ""
#: Code/Lib/Channel.php:2170 Code/Module/Rmagic.php:88 boot.php:1127
#: Code/Lib/Channel.php:2164 Code/Module/Rmagic.php:88 boot.php:1127
msgid "Remote Authentication"
msgstr ""
#: Code/Lib/Channel.php:2171 Code/Module/Rmagic.php:89
#: Code/Lib/Channel.php:2165 Code/Module/Rmagic.php:89
msgid "Enter your channel address (e.g. channel@example.com)"
msgstr ""
#: Code/Lib/Channel.php:2172 Code/Module/Rmagic.php:92
#: Code/Lib/Channel.php:2166 Code/Module/Rmagic.php:92
msgid "Authenticate"
msgstr ""
@ -1363,31 +1422,31 @@ msgstr ""
msgid "Room is full"
msgstr ""
#: Code/Lib/Connect.php:58 Code/Lib/Connect.php:178
#: Code/Lib/Connect.php:56 Code/Lib/Connect.php:175
msgid "Channel is blocked on this site."
msgstr ""
#: Code/Lib/Connect.php:63
#: Code/Lib/Connect.php:61
msgid "Channel location missing."
msgstr ""
#: Code/Lib/Connect.php:140
#: Code/Lib/Connect.php:138
msgid "Remote channel or protocol unavailable."
msgstr ""
#: Code/Lib/Connect.php:172
#: Code/Lib/Connect.php:169
msgid "Channel discovery failed."
msgstr ""
#: Code/Lib/Connect.php:185
#: Code/Lib/Connect.php:182
msgid "Protocol not supported"
msgstr ""
#: Code/Lib/Connect.php:198
#: Code/Lib/Connect.php:195
msgid "Cannot connect to yourself."
msgstr ""
#: Code/Lib/Connect.php:276
#: Code/Lib/Connect.php:273
msgid "error saving data"
msgstr ""
@ -2284,65 +2343,6 @@ msgstr ""
msgid "&#x1F4E2; Repeated %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:473
msgid "Quoted post"
msgstr ""
#: Code/Lib/Activity.php:3071
msgid "Activity"
msgstr ""
#: Code/Lib/Activity.php:3077
#, php-format
msgid "Likes %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3080
#, php-format
msgid "Doesn't like %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3083
#, php-format
msgid "Flagged %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3086
#, php-format
msgid "Blocked %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3094
#, php-format
msgid "Will attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3097
#, php-format
msgid "Will not attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3100
#, php-format
msgid "May attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3103
#, php-format
msgid "May not attend %s's event"
msgstr ""
#: Code/Lib/Activity.php:3108
#, php-format
msgid "&#x1f4e2; Repeated %1$s's %2$s"
msgstr ""
#: Code/Lib/Activity.php:3705 include/misc.php:1668 include/misc.php:3129
#: include/items.php:3006
#, php-format
msgid "%1$s (%2$s)"
msgstr ""
#: Code/Lib/Libzotdir.php:88
msgid "Directory Options"
msgstr ""
@ -7447,7 +7447,7 @@ msgstr ""
msgid "Restricted or Premium Channel"
msgstr ""
#: Code/Module/Follow.php:151
#: Code/Module/Follow.php:146
msgid "Connection added."
msgstr ""

View file

@ -1,2 +1,2 @@
<?php
define ('STD_VERSION', '23.11.28');
define ('STD_VERSION', '23.12.04');