Merge pull request #10472 from annando/proxy
Simplified proxy, item cache related stuff removed
This commit is contained in:
commit
6354d7c81d
|
@ -1,4 +1,6 @@
|
|||
Version 2021.09 (unreleased)
|
||||
Friendica Core
|
||||
Simplified the proxy mechanism. The proxy cache directory (/proxy) can now be removed [annando]
|
||||
|
||||
Version 2021.07 (2021-07-04)
|
||||
Friendica Core
|
||||
|
|
87
boot.php
87
boot.php
|
@ -444,93 +444,6 @@ function get_temppath()
|
|||
return '';
|
||||
}
|
||||
|
||||
function get_cachefile($file, $writemode = true)
|
||||
{
|
||||
$cache = get_itemcachepath();
|
||||
|
||||
if ((!$cache) || (!is_dir($cache))) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$subfolder = $cache . "/" . substr($file, 0, 2);
|
||||
|
||||
$cachepath = $subfolder . "/" . $file;
|
||||
|
||||
if ($writemode) {
|
||||
if (!is_dir($subfolder)) {
|
||||
mkdir($subfolder);
|
||||
chmod($subfolder, 0777);
|
||||
}
|
||||
}
|
||||
|
||||
return $cachepath;
|
||||
}
|
||||
|
||||
function clear_cache($basepath = "", $path = "")
|
||||
{
|
||||
if ($path == "") {
|
||||
$basepath = get_itemcachepath();
|
||||
$path = $basepath;
|
||||
}
|
||||
|
||||
if (($path == "") || (!is_dir($path))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (substr(realpath($path), 0, strlen($basepath)) != $basepath) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cachetime = (int) DI::config()->get('system', 'itemcache_duration');
|
||||
if ($cachetime == 0) {
|
||||
$cachetime = 86400;
|
||||
}
|
||||
|
||||
if (is_writable($path)) {
|
||||
if ($dh = opendir($path)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
$fullpath = $path . "/" . $file;
|
||||
if ((filetype($fullpath) == "dir") && ($file != ".") && ($file != "..")) {
|
||||
clear_cache($basepath, $fullpath);
|
||||
}
|
||||
if ((filetype($fullpath) == "file") && (filectime($fullpath) < (time() - $cachetime))) {
|
||||
unlink($fullpath);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_itemcachepath()
|
||||
{
|
||||
// Checking, if the cache is deactivated
|
||||
$cachetime = (int) DI::config()->get('system', 'itemcache_duration');
|
||||
if ($cachetime < 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$itemcache = DI::config()->get('system', 'itemcache');
|
||||
if (($itemcache != "") && System::isDirectoryUsable($itemcache)) {
|
||||
return BasePath::getRealPath($itemcache);
|
||||
}
|
||||
|
||||
$temppath = get_temppath();
|
||||
|
||||
if ($temppath != "") {
|
||||
$itemcache = $temppath . "/itemcache";
|
||||
if (!file_exists($itemcache) && !is_dir($itemcache)) {
|
||||
mkdir($itemcache);
|
||||
}
|
||||
|
||||
if (System::isDirectoryUsable($itemcache)) {
|
||||
DI::config()->set("system", "itemcache", $itemcache);
|
||||
return $itemcache;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path where spool files are stored
|
||||
*
|
||||
|
|
58
database.sql
58
database.sql
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2021.06-rc (Siberian Iris)
|
||||
-- DB_UPDATE_VERSION 1424
|
||||
-- Friendica 2021.09-dev (Siberian Iris)
|
||||
-- DB_UPDATE_VERSION 1426
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -94,6 +94,18 @@ CREATE TABLE IF NOT EXISTS `user` (
|
|||
FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
|
||||
|
||||
--
|
||||
-- TABLE item-uri
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `item-uri` (
|
||||
`id` int unsigned NOT NULL auto_increment,
|
||||
`uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
|
||||
`guid` varbinary(255) COMMENT 'A unique identifier for an item',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `uri` (`uri`),
|
||||
INDEX `guid` (`guid`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
|
||||
|
||||
--
|
||||
-- TABLE contact
|
||||
--
|
||||
|
@ -126,6 +138,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
|||
`dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
|
||||
`addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`pubkey` text COMMENT 'RSA public key 4096 bit',
|
||||
|
@ -202,22 +215,12 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
|||
INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
|
||||
INDEX `self_network_uid` (`self`,`network`,`uid`),
|
||||
INDEX `gsid` (`gsid`),
|
||||
INDEX `uri-id` (`uri-id`),
|
||||
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
|
||||
|
||||
--
|
||||
-- TABLE item-uri
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `item-uri` (
|
||||
`id` int unsigned NOT NULL auto_increment,
|
||||
`uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
|
||||
`guid` varbinary(255) COMMENT 'A unique identifier for an item',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `uri` (`uri`),
|
||||
INDEX `guid` (`guid`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
|
||||
|
||||
--
|
||||
-- TABLE tag
|
||||
--
|
||||
|
@ -332,6 +335,7 @@ CREATE TABLE IF NOT EXISTS `addon` (
|
|||
--
|
||||
CREATE TABLE IF NOT EXISTS `apcontact` (
|
||||
`url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
|
||||
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
|
||||
`uuid` varchar(255) COMMENT '',
|
||||
`type` varchar(20) NOT NULL COMMENT '',
|
||||
`following` varchar(255) COMMENT '',
|
||||
|
@ -364,6 +368,8 @@ CREATE TABLE IF NOT EXISTS `apcontact` (
|
|||
INDEX `baseurl` (`baseurl`(190)),
|
||||
INDEX `sharedinbox` (`sharedinbox`(190)),
|
||||
INDEX `gsid` (`gsid`),
|
||||
UNIQUE INDEX `uri-id` (`uri-id`),
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
|
||||
|
||||
|
@ -563,6 +569,7 @@ CREATE TABLE IF NOT EXISTS `event` (
|
|||
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
|
||||
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
|
||||
`uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
|
||||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
|
||||
`edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
|
||||
`start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
|
||||
|
@ -581,8 +588,10 @@ CREATE TABLE IF NOT EXISTS `event` (
|
|||
PRIMARY KEY(`id`),
|
||||
INDEX `uid_start` (`uid`,`start`),
|
||||
INDEX `cid` (`cid`),
|
||||
INDEX `uri-id` (`uri-id`),
|
||||
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
|
||||
|
||||
--
|
||||
|
@ -592,6 +601,7 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
|
|||
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
|
||||
`guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
|
||||
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
|
||||
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
|
@ -608,7 +618,9 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
|
|||
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `addr` (`addr`(32)),
|
||||
UNIQUE INDEX `url` (`url`(190))
|
||||
UNIQUE INDEX `url` (`url`(190)),
|
||||
UNIQUE INDEX `uri-id` (`uri-id`),
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
|
||||
|
||||
--
|
||||
|
@ -1103,6 +1115,19 @@ CREATE TABLE IF NOT EXISTS `post-delivery-data` (
|
|||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
|
||||
|
||||
--
|
||||
-- TABLE post-link
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `post-link` (
|
||||
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
|
||||
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
|
||||
`url` varbinary(511) NOT NULL COMMENT 'External URL',
|
||||
`mimetype` varchar(60) COMMENT '',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post related external links';
|
||||
|
||||
--
|
||||
-- TABLE post-media
|
||||
--
|
||||
|
@ -1278,6 +1303,7 @@ CREATE TABLE IF NOT EXISTS `post-thread-user` (
|
|||
INDEX `post-user-id` (`post-user-id`),
|
||||
INDEX `commented` (`commented`),
|
||||
INDEX `uid_received` (`uid`,`received`),
|
||||
INDEX `uid_wall_received` (`uid`,`wall`,`received`),
|
||||
INDEX `uid_pinned` (`uid`,`pinned`),
|
||||
INDEX `uid_commented` (`uid`,`commented`),
|
||||
INDEX `uid_starred` (`uid`,`starred`),
|
||||
|
|
|
@ -53,6 +53,7 @@ Database Tables
|
|||
| [post-category](help/database/db_post-category) | post relation to categories |
|
||||
| [post-content](help/database/db_post-content) | Content for all posts |
|
||||
| [post-delivery-data](help/database/db_post-delivery-data) | Delivery data for items |
|
||||
| [post-link](help/database/db_post-link) | Post related external links |
|
||||
| [post-media](help/database/db_post-media) | Attached media |
|
||||
| [post-tag](help/database/db_post-tag) | post relation to tags |
|
||||
| [post-thread](help/database/db_post-thread) | Thread related data |
|
||||
|
|
|
@ -9,6 +9,7 @@ Fields
|
|||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| ---------------- | ------------------------------------------------------------------- | -------------- | ---- | --- | ------------------- | ----- |
|
||||
| url | URL of the contact | varbinary(255) | NO | PRI | NULL | |
|
||||
| uri-id | Id of the item-uri table entry that contains the apcontact url | int unsigned | YES | | NULL | |
|
||||
| uuid | | varchar(255) | YES | | NULL | |
|
||||
| type | | varchar(20) | NO | | NULL | |
|
||||
| following | | varchar(255) | YES | | NULL | |
|
||||
|
@ -47,12 +48,14 @@ Indexes
|
|||
| baseurl | baseurl(190) |
|
||||
| sharedinbox | sharedinbox(190) |
|
||||
| gsid | gsid |
|
||||
| uri-id | UNIQUE, uri-id |
|
||||
|
||||
Foreign Keys
|
||||
------------
|
||||
|
||||
| Field | Target Table | Target Field |
|
||||
|-------|--------------|--------------|
|
||||
| uri-id | [item-uri](help/database/db_item-uri) | id |
|
||||
| gsid | [gserver](help/database/db_gserver) | id |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -6,89 +6,90 @@ contact table
|
|||
Fields
|
||||
------
|
||||
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| ------------------------- | --------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
|
||||
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
|
||||
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| updated | Date of last contact update | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
| self | 1 if the contact is the user him/her self | boolean | NO | | 0 | |
|
||||
| remote_self | | boolean | NO | | 0 | |
|
||||
| rel | The kind of the relation between the user and the contact | tinyint unsigned | NO | | 0 | |
|
||||
| duplex | | boolean | NO | | 0 | |
|
||||
| network | Network of the contact | char(4) | NO | | | |
|
||||
| protocol | Protocol of the contact | char(4) | NO | | | |
|
||||
| name | Name that this contact is known by | varchar(255) | NO | | | |
|
||||
| nick | Nick- and user name of the contact | varchar(255) | NO | | | |
|
||||
| location | | varchar(255) | YES | | | |
|
||||
| about | | text | YES | | NULL | |
|
||||
| keywords | public keywords (interests) of the contact | text | YES | | NULL | |
|
||||
| gender | Deprecated | varchar(32) | NO | | | |
|
||||
| xmpp | | varchar(255) | NO | | | |
|
||||
| attag | | varchar(255) | NO | | | |
|
||||
| avatar | | varchar(255) | NO | | | |
|
||||
| photo | Link to the profile photo of the contact | varchar(255) | YES | | | |
|
||||
| thumb | Link to the profile photo (thumb size) | varchar(255) | YES | | | |
|
||||
| micro | Link to the profile photo (micro size) | varchar(255) | YES | | | |
|
||||
| header | Header picture | varchar(255) | YES | | NULL | |
|
||||
| site-pubkey | | text | YES | | NULL | |
|
||||
| issued-id | | varchar(255) | NO | | | |
|
||||
| dfrn-id | | varchar(255) | NO | | | |
|
||||
| url | | varchar(255) | NO | | | |
|
||||
| nurl | | varchar(255) | NO | | | |
|
||||
| addr | | varchar(255) | NO | | | |
|
||||
| alias | | varchar(255) | NO | | | |
|
||||
| pubkey | RSA public key 4096 bit | text | YES | | NULL | |
|
||||
| prvkey | RSA private key 4096 bit | text | YES | | NULL | |
|
||||
| batch | | varchar(255) | NO | | | |
|
||||
| request | | varchar(255) | YES | | NULL | |
|
||||
| notify | | varchar(255) | YES | | NULL | |
|
||||
| poll | | varchar(255) | YES | | NULL | |
|
||||
| confirm | | varchar(255) | YES | | NULL | |
|
||||
| subscribe | | varchar(255) | YES | | NULL | |
|
||||
| poco | | varchar(255) | YES | | NULL | |
|
||||
| aes_allow | | boolean | NO | | 0 | |
|
||||
| ret-aes | | boolean | NO | | 0 | |
|
||||
| usehub | | boolean | NO | | 0 | |
|
||||
| subhub | | boolean | NO | | 0 | |
|
||||
| hub-verify | | varchar(255) | NO | | | |
|
||||
| last-update | Date of the last try to update the contact info | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| success_update | Date of the last successful contact update | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| failure_update | Date of the last failed update | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| failed | Connection failed | boolean | YES | | NULL | |
|
||||
| name-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| uri-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| avatar-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| term-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| last-item | date of the last post | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| last-discovery | date of the last follower discovery | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| priority | | tinyint unsigned | NO | | 0 | |
|
||||
| blocked | Node-wide block status | boolean | NO | | 1 | |
|
||||
| block_reason | Node-wide block reason | text | YES | | NULL | |
|
||||
| readonly | posts of the contact are readonly | boolean | NO | | 0 | |
|
||||
| writable | | boolean | NO | | 0 | |
|
||||
| forum | contact is a forum | boolean | NO | | 0 | |
|
||||
| prv | contact is a private group | boolean | NO | | 0 | |
|
||||
| contact-type | | tinyint | NO | | 0 | |
|
||||
| manually-approve | | boolean | YES | | NULL | |
|
||||
| hidden | | boolean | NO | | 0 | |
|
||||
| archive | | boolean | NO | | 0 | |
|
||||
| pending | | boolean | NO | | 1 | |
|
||||
| deleted | Contact has been deleted | boolean | NO | | 0 | |
|
||||
| rating | | tinyint | NO | | 0 | |
|
||||
| unsearchable | Contact prefers to not be searchable | boolean | NO | | 0 | |
|
||||
| sensitive | Contact posts sensitive content | boolean | NO | | 0 | |
|
||||
| baseurl | baseurl of the contact | varchar(255) | YES | | | |
|
||||
| gsid | Global Server ID | int unsigned | YES | | NULL | |
|
||||
| reason | | text | YES | | NULL | |
|
||||
| closeness | | tinyint unsigned | NO | | 99 | |
|
||||
| info | | mediumtext | YES | | NULL | |
|
||||
| profile-id | Deprecated | int unsigned | YES | | NULL | |
|
||||
| bdyear | | varchar(4) | NO | | | |
|
||||
| bd | | date | NO | | 0001-01-01 | |
|
||||
| notify_new_posts | | boolean | NO | | 0 | |
|
||||
| fetch_further_information | | tinyint unsigned | NO | | 0 | |
|
||||
| ffi_keyword_denylist | | text | YES | | NULL | |
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| ------------------------- | ------------------------------------------------------------ | ------------------ | ---- | --- | ------------------- | -------------- |
|
||||
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
|
||||
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
|
||||
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| updated | Date of last contact update | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
| self | 1 if the contact is the user him/her self | boolean | NO | | 0 | |
|
||||
| remote_self | | boolean | NO | | 0 | |
|
||||
| rel | The kind of the relation between the user and the contact | tinyint unsigned | NO | | 0 | |
|
||||
| duplex | | boolean | NO | | 0 | |
|
||||
| network | Network of the contact | char(4) | NO | | | |
|
||||
| protocol | Protocol of the contact | char(4) | NO | | | |
|
||||
| name | Name that this contact is known by | varchar(255) | NO | | | |
|
||||
| nick | Nick- and user name of the contact | varchar(255) | NO | | | |
|
||||
| location | | varchar(255) | YES | | | |
|
||||
| about | | text | YES | | NULL | |
|
||||
| keywords | public keywords (interests) of the contact | text | YES | | NULL | |
|
||||
| gender | Deprecated | varchar(32) | NO | | | |
|
||||
| xmpp | | varchar(255) | NO | | | |
|
||||
| attag | | varchar(255) | NO | | | |
|
||||
| avatar | | varchar(255) | NO | | | |
|
||||
| photo | Link to the profile photo of the contact | varchar(255) | YES | | | |
|
||||
| thumb | Link to the profile photo (thumb size) | varchar(255) | YES | | | |
|
||||
| micro | Link to the profile photo (micro size) | varchar(255) | YES | | | |
|
||||
| header | Header picture | varchar(255) | YES | | NULL | |
|
||||
| site-pubkey | | text | YES | | NULL | |
|
||||
| issued-id | | varchar(255) | NO | | | |
|
||||
| dfrn-id | | varchar(255) | NO | | | |
|
||||
| url | | varchar(255) | NO | | | |
|
||||
| nurl | | varchar(255) | NO | | | |
|
||||
| uri-id | Id of the item-uri table entry that contains the contact url | int unsigned | YES | | NULL | |
|
||||
| addr | | varchar(255) | NO | | | |
|
||||
| alias | | varchar(255) | NO | | | |
|
||||
| pubkey | RSA public key 4096 bit | text | YES | | NULL | |
|
||||
| prvkey | RSA private key 4096 bit | text | YES | | NULL | |
|
||||
| batch | | varchar(255) | NO | | | |
|
||||
| request | | varchar(255) | YES | | NULL | |
|
||||
| notify | | varchar(255) | YES | | NULL | |
|
||||
| poll | | varchar(255) | YES | | NULL | |
|
||||
| confirm | | varchar(255) | YES | | NULL | |
|
||||
| subscribe | | varchar(255) | YES | | NULL | |
|
||||
| poco | | varchar(255) | YES | | NULL | |
|
||||
| aes_allow | | boolean | NO | | 0 | |
|
||||
| ret-aes | | boolean | NO | | 0 | |
|
||||
| usehub | | boolean | NO | | 0 | |
|
||||
| subhub | | boolean | NO | | 0 | |
|
||||
| hub-verify | | varchar(255) | NO | | | |
|
||||
| last-update | Date of the last try to update the contact info | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| success_update | Date of the last successful contact update | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| failure_update | Date of the last failed update | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| failed | Connection failed | boolean | YES | | NULL | |
|
||||
| name-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| uri-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| avatar-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| term-date | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| last-item | date of the last post | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| last-discovery | date of the last follower discovery | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| priority | | tinyint unsigned | NO | | 0 | |
|
||||
| blocked | Node-wide block status | boolean | NO | | 1 | |
|
||||
| block_reason | Node-wide block reason | text | YES | | NULL | |
|
||||
| readonly | posts of the contact are readonly | boolean | NO | | 0 | |
|
||||
| writable | | boolean | NO | | 0 | |
|
||||
| forum | contact is a forum | boolean | NO | | 0 | |
|
||||
| prv | contact is a private group | boolean | NO | | 0 | |
|
||||
| contact-type | | tinyint | NO | | 0 | |
|
||||
| manually-approve | | boolean | YES | | NULL | |
|
||||
| hidden | | boolean | NO | | 0 | |
|
||||
| archive | | boolean | NO | | 0 | |
|
||||
| pending | | boolean | NO | | 1 | |
|
||||
| deleted | Contact has been deleted | boolean | NO | | 0 | |
|
||||
| rating | | tinyint | NO | | 0 | |
|
||||
| unsearchable | Contact prefers to not be searchable | boolean | NO | | 0 | |
|
||||
| sensitive | Contact posts sensitive content | boolean | NO | | 0 | |
|
||||
| baseurl | baseurl of the contact | varchar(255) | YES | | | |
|
||||
| gsid | Global Server ID | int unsigned | YES | | NULL | |
|
||||
| reason | | text | YES | | NULL | |
|
||||
| closeness | | tinyint unsigned | NO | | 99 | |
|
||||
| info | | mediumtext | YES | | NULL | |
|
||||
| profile-id | Deprecated | int unsigned | YES | | NULL | |
|
||||
| bdyear | | varchar(4) | NO | | | |
|
||||
| bd | | date | NO | | 0001-01-01 | |
|
||||
| notify_new_posts | | boolean | NO | | 0 | |
|
||||
| fetch_further_information | | tinyint unsigned | NO | | 0 | |
|
||||
| ffi_keyword_denylist | | text | YES | | NULL | |
|
||||
|
||||
Indexes
|
||||
------------
|
||||
|
@ -118,6 +119,7 @@ Indexes
|
|||
| uid_self_contact-type | uid, self, contact-type |
|
||||
| self_network_uid | self, network, uid |
|
||||
| gsid | gsid |
|
||||
| uri-id | uri-id |
|
||||
|
||||
Foreign Keys
|
||||
------------
|
||||
|
@ -125,6 +127,7 @@ Foreign Keys
|
|||
| Field | Target Table | Target Field |
|
||||
|-------|--------------|--------------|
|
||||
| uid | [user](help/database/db_user) | uid |
|
||||
| uri-id | [item-uri](help/database/db_item-uri) | id |
|
||||
| gsid | [gserver](help/database/db_gserver) | id |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -6,28 +6,29 @@ Events
|
|||
Fields
|
||||
------
|
||||
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| --------- | ------------------------------------------------------ | ------------------ | ---- | --- | ------------------- | -------------- |
|
||||
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
|
||||
| guid | | varchar(255) | NO | | | |
|
||||
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
|
||||
| cid | contact_id (ID of the contact in contact table) | int unsigned | NO | | 0 | |
|
||||
| uri | | varchar(255) | NO | | | |
|
||||
| created | creation time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| edited | last edit time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| start | event start time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| finish | event end time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| summary | short description or title of the event | text | YES | | NULL | |
|
||||
| desc | event description | text | YES | | NULL | |
|
||||
| location | event location | text | YES | | NULL | |
|
||||
| type | event or birthday | varchar(20) | NO | | | |
|
||||
| nofinish | if event does have no end this is 1 | boolean | NO | | 0 | |
|
||||
| adjust | adjust to timezone of the recipient (0 or 1) | boolean | NO | | 1 | |
|
||||
| ignore | 0 or 1 | boolean | NO | | 0 | |
|
||||
| allow_cid | Access Control - list of allowed contact.id '<19><78>' | mediumtext | YES | | NULL | |
|
||||
| allow_gid | Access Control - list of allowed groups | mediumtext | YES | | NULL | |
|
||||
| deny_cid | Access Control - list of denied contact.id | mediumtext | YES | | NULL | |
|
||||
| deny_gid | Access Control - list of denied groups | mediumtext | YES | | NULL | |
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| --------- | ---------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
|
||||
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
|
||||
| guid | | varchar(255) | NO | | | |
|
||||
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
|
||||
| cid | contact_id (ID of the contact in contact table) | int unsigned | NO | | 0 | |
|
||||
| uri | | varchar(255) | NO | | | |
|
||||
| uri-id | Id of the item-uri table entry that contains the event uri | int unsigned | YES | | NULL | |
|
||||
| created | creation time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| edited | last edit time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| start | event start time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| finish | event end time | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| summary | short description or title of the event | text | YES | | NULL | |
|
||||
| desc | event description | text | YES | | NULL | |
|
||||
| location | event location | text | YES | | NULL | |
|
||||
| type | event or birthday | varchar(20) | NO | | | |
|
||||
| nofinish | if event does have no end this is 1 | boolean | NO | | 0 | |
|
||||
| adjust | adjust to timezone of the recipient (0 or 1) | boolean | NO | | 1 | |
|
||||
| ignore | 0 or 1 | boolean | NO | | 0 | |
|
||||
| allow_cid | Access Control - list of allowed contact.id '<19><78>' | mediumtext | YES | | NULL | |
|
||||
| allow_gid | Access Control - list of allowed groups | mediumtext | YES | | NULL | |
|
||||
| deny_cid | Access Control - list of denied contact.id | mediumtext | YES | | NULL | |
|
||||
| deny_gid | Access Control - list of denied groups | mediumtext | YES | | NULL | |
|
||||
|
||||
Indexes
|
||||
------------
|
||||
|
@ -37,6 +38,7 @@ Indexes
|
|||
| PRIMARY | id |
|
||||
| uid_start | uid, start |
|
||||
| cid | cid |
|
||||
| uri-id | uri-id |
|
||||
|
||||
Foreign Keys
|
||||
------------
|
||||
|
@ -45,5 +47,6 @@ Foreign Keys
|
|||
|-------|--------------|--------------|
|
||||
| uid | [user](help/database/db_user) | uid |
|
||||
| cid | [contact](help/database/db_contact) | id |
|
||||
| uri-id | [item-uri](help/database/db_item-uri) | id |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -6,25 +6,26 @@ Diaspora compatible contacts - used in the Diaspora implementation
|
|||
Fields
|
||||
------
|
||||
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| -------- | ------------- | ---------------- | ---- | --- | ------------------- | -------------- |
|
||||
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
|
||||
| guid | unique id | varchar(255) | NO | | | |
|
||||
| url | | varchar(255) | NO | | | |
|
||||
| name | | varchar(255) | NO | | | |
|
||||
| photo | | varchar(255) | NO | | | |
|
||||
| request | | varchar(255) | NO | | | |
|
||||
| nick | | varchar(255) | NO | | | |
|
||||
| addr | | varchar(255) | NO | | | |
|
||||
| batch | | varchar(255) | NO | | | |
|
||||
| notify | | varchar(255) | NO | | | |
|
||||
| poll | | varchar(255) | NO | | | |
|
||||
| confirm | | varchar(255) | NO | | | |
|
||||
| priority | | tinyint unsigned | NO | | 0 | |
|
||||
| network | | char(4) | NO | | | |
|
||||
| alias | | varchar(255) | NO | | | |
|
||||
| pubkey | | text | YES | | NULL | |
|
||||
| updated | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| -------- | ------------------------------------------------------------- | ---------------- | ---- | --- | ------------------- | -------------- |
|
||||
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
|
||||
| guid | unique id | varchar(255) | NO | | | |
|
||||
| url | | varchar(255) | NO | | | |
|
||||
| uri-id | Id of the item-uri table entry that contains the fcontact url | int unsigned | YES | | NULL | |
|
||||
| name | | varchar(255) | NO | | | |
|
||||
| photo | | varchar(255) | NO | | | |
|
||||
| request | | varchar(255) | NO | | | |
|
||||
| nick | | varchar(255) | NO | | | |
|
||||
| addr | | varchar(255) | NO | | | |
|
||||
| batch | | varchar(255) | NO | | | |
|
||||
| notify | | varchar(255) | NO | | | |
|
||||
| poll | | varchar(255) | NO | | | |
|
||||
| confirm | | varchar(255) | NO | | | |
|
||||
| priority | | tinyint unsigned | NO | | 0 | |
|
||||
| network | | char(4) | NO | | | |
|
||||
| alias | | varchar(255) | NO | | | |
|
||||
| pubkey | | text | YES | | NULL | |
|
||||
| updated | | datetime | NO | | 0001-01-01 00:00:00 | |
|
||||
|
||||
Indexes
|
||||
------------
|
||||
|
@ -34,6 +35,13 @@ Indexes
|
|||
| PRIMARY | id |
|
||||
| addr | addr(32) |
|
||||
| url | UNIQUE, url(190) |
|
||||
| uri-id | UNIQUE, uri-id |
|
||||
|
||||
Foreign Keys
|
||||
------------
|
||||
|
||||
| Field | Target Table | Target Field |
|
||||
|-------|--------------|--------------|
|
||||
| uri-id | [item-uri](help/database/db_item-uri) | id |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
31
doc/database/db_post-link.md
Normal file
31
doc/database/db_post-link.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
Table post-link
|
||||
===========
|
||||
|
||||
Post related external links
|
||||
|
||||
Fields
|
||||
------
|
||||
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| -------- | --------------------------------------------------------- | -------------- | ---- | --- | ------- | -------------- |
|
||||
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
|
||||
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | | NULL | |
|
||||
| url | External URL | varbinary(511) | NO | | NULL | |
|
||||
| mimetype | | varchar(60) | YES | | NULL | |
|
||||
|
||||
Indexes
|
||||
------------
|
||||
|
||||
| Name | Fields |
|
||||
| ---------- | ------------------- |
|
||||
| PRIMARY | id |
|
||||
| uri-id-url | UNIQUE, uri-id, url |
|
||||
|
||||
Foreign Keys
|
||||
------------
|
||||
|
||||
| Field | Target Table | Target Field |
|
||||
|-------|--------------|--------------|
|
||||
| uri-id | [item-uri](help/database/db_item-uri) | id |
|
||||
|
||||
Return to [database documentation](help/database)
|
|
@ -35,23 +35,24 @@ Fields
|
|||
Indexes
|
||||
------------
|
||||
|
||||
| Name | Fields |
|
||||
| ------------- | -------------- |
|
||||
| PRIMARY | uid, uri-id |
|
||||
| uri-id | uri-id |
|
||||
| owner-id | owner-id |
|
||||
| author-id | author-id |
|
||||
| causer-id | causer-id |
|
||||
| uid | uid |
|
||||
| contact-id | contact-id |
|
||||
| psid | psid |
|
||||
| post-user-id | post-user-id |
|
||||
| commented | commented |
|
||||
| uid_received | uid, received |
|
||||
| uid_pinned | uid, pinned |
|
||||
| uid_commented | uid, commented |
|
||||
| uid_starred | uid, starred |
|
||||
| uid_mention | uid, mention |
|
||||
| Name | Fields |
|
||||
| ----------------- | ------------------- |
|
||||
| PRIMARY | uid, uri-id |
|
||||
| uri-id | uri-id |
|
||||
| owner-id | owner-id |
|
||||
| author-id | author-id |
|
||||
| causer-id | causer-id |
|
||||
| uid | uid |
|
||||
| contact-id | contact-id |
|
||||
| psid | psid |
|
||||
| post-user-id | post-user-id |
|
||||
| commented | commented |
|
||||
| uid_received | uid, received |
|
||||
| uid_wall_received | uid, wall, received |
|
||||
| uid_pinned | uid, pinned |
|
||||
| uid_commented | uid, commented |
|
||||
| uid_starred | uid, starred |
|
||||
| uid_mention | uid, mention |
|
||||
|
||||
Foreign Keys
|
||||
------------
|
||||
|
|
|
@ -64,7 +64,6 @@ use Friendica\Security\OAuth1\OAuthUtil;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -2552,10 +2551,10 @@ function api_convert_item($item)
|
|||
{
|
||||
$body = api_add_attachments_to_body($item);
|
||||
|
||||
$entities = api_get_entitities($statustext, $body);
|
||||
$entities = api_get_entitities($statustext, $body, $item['uri-id']);
|
||||
|
||||
// Add pictures to the attachment array and remove them from the body
|
||||
$attachments = api_get_attachments($body);
|
||||
$attachments = api_get_attachments($body, $item['uri-id']);
|
||||
|
||||
// Workaround for ostatus messages where the title is identically to the body
|
||||
$html = BBCode::convert(api_clean_plain_items($body), false, BBCode::API, true);
|
||||
|
@ -2650,11 +2649,12 @@ function api_add_attachments_to_body(array $item)
|
|||
/**
|
||||
*
|
||||
* @param string $body
|
||||
* @param int $uriid
|
||||
*
|
||||
* @return array
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
function api_get_attachments(&$body)
|
||||
function api_get_attachments(&$body, $uriid)
|
||||
{
|
||||
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
|
||||
$body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $body);
|
||||
|
@ -2675,11 +2675,7 @@ function api_get_attachments(&$body)
|
|||
$imagedata = Images::getInfoFromURLCached($image);
|
||||
|
||||
if ($imagedata) {
|
||||
if (DI::config()->get("system", "proxy_disabled")) {
|
||||
$attachments[] = ["url" => $image, "mimetype" => $imagedata["mime"], "size" => $imagedata["size"]];
|
||||
} else {
|
||||
$attachments[] = ["url" => ProxyUtils::proxifyUrl($image, false), "mimetype" => $imagedata["mime"], "size" => $imagedata["size"]];
|
||||
}
|
||||
$attachments[] = ["url" => Post\Link::getByLink($uriid, $image), "mimetype" => $imagedata["mime"], "size" => $imagedata["size"]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2695,7 +2691,7 @@ function api_get_attachments(&$body)
|
|||
* @throws InternalServerErrorException
|
||||
* @todo Links at the first character of the post
|
||||
*/
|
||||
function api_get_entitities(&$text, $bbcode)
|
||||
function api_get_entitities(&$text, $bbcode, $uriid)
|
||||
{
|
||||
$include_entities = strtolower($_REQUEST['include_entities'] ?? 'false');
|
||||
|
||||
|
@ -2703,7 +2699,7 @@ function api_get_entitities(&$text, $bbcode)
|
|||
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
|
||||
|
||||
foreach ($images[1] as $image) {
|
||||
$replace = ProxyUtils::proxifyUrl($image, false);
|
||||
$replace = Post\Link::getByLink($uriid, $image);
|
||||
$text = str_replace($image, $replace, $text);
|
||||
}
|
||||
return [];
|
||||
|
@ -2815,31 +2811,8 @@ function api_get_entitities(&$text, $bbcode)
|
|||
if (!($start === false)) {
|
||||
$image = Images::getInfoFromURLCached($url);
|
||||
if ($image) {
|
||||
// If image cache is activated, then use the following sizes:
|
||||
// thumb (150), small (340), medium (600) and large (1024)
|
||||
if (!DI::config()->get("system", "proxy_disabled")) {
|
||||
$media_url = ProxyUtils::proxifyUrl($url, false);
|
||||
|
||||
$sizes = [];
|
||||
$scale = Images::getScalingDimensions($image[0], $image[1], 150);
|
||||
$sizes["thumb"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
|
||||
|
||||
if (($image[0] > 150) || ($image[1] > 150)) {
|
||||
$scale = Images::getScalingDimensions($image[0], $image[1], 340);
|
||||
$sizes["small"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
|
||||
}
|
||||
|
||||
$scale = Images::getScalingDimensions($image[0], $image[1], 600);
|
||||
$sizes["medium"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
|
||||
|
||||
if (($image[0] > 600) || ($image[1] > 600)) {
|
||||
$scale = Images::getScalingDimensions($image[0], $image[1], 1024);
|
||||
$sizes["large"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
|
||||
}
|
||||
} else {
|
||||
$media_url = $url;
|
||||
$sizes["medium"] = ["w" => $image[0], "h" => $image[1], "resize" => "fit"];
|
||||
}
|
||||
$media_url = Post\Link::getByLink($uriid, $url);
|
||||
$sizes["medium"] = ["w" => $image[0], "h" => $image[1], "resize" => "fit"];
|
||||
|
||||
$entities["media"][] = [
|
||||
"id" => $start+1,
|
||||
|
|
|
@ -334,8 +334,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
$o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid);
|
||||
|
||||
// Preparing the meta header
|
||||
$description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true));
|
||||
$title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true));
|
||||
$description = trim(BBCode::toPlaintext($item["body"]));
|
||||
$title = trim(BBCode::toPlaintext($item["title"]));
|
||||
$author_name = $item["author-name"];
|
||||
|
||||
$image = DI::baseUrl()->remove($item["author-avatar"]);
|
||||
|
|
|
@ -325,7 +325,7 @@ function message_content(App $a)
|
|||
$to_name_e = $message['name'];
|
||||
|
||||
$contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar']);
|
||||
$from_photo = Contact::getThumb($contact, $message['from-photo']);
|
||||
$from_photo = Contact::getThumb($contact);
|
||||
|
||||
$mails[] = [
|
||||
'id' => $message['id'],
|
||||
|
@ -457,7 +457,7 @@ function render_messages(array $msg, $t)
|
|||
}
|
||||
|
||||
$contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr', 'id', 'avatar']);
|
||||
$from_photo = Contact::getThumb($contact, $rr['thumb'] ?: $rr['from-photo']);
|
||||
$from_photo = Contact::getThumb($contact);
|
||||
|
||||
$rslt .= Renderer::replaceMacros($tpl, [
|
||||
'$id' => $rr['id'],
|
||||
|
|
|
@ -37,6 +37,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Event;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
@ -251,7 +252,7 @@ class BBCode
|
|||
$post = self::getAttachmentData($body);
|
||||
|
||||
// Get all linked images with alternative image description
|
||||
if (preg_match_all("/\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) {
|
||||
if (preg_match_all("/\[img=(http[^\[\]]*)\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) {
|
||||
foreach ($pictures as $picture) {
|
||||
if (Photo::isLocal($picture[1])) {
|
||||
$post['images'][] = ['url' => str_replace('-1.', '-0.', $picture[1]), 'description' => $picture[2]];
|
||||
|
@ -433,18 +434,27 @@ class BBCode
|
|||
*/
|
||||
public static function toPlaintext($text, $keep_urls = true)
|
||||
{
|
||||
// Remove pictures in advance to avoid unneeded proxy calls
|
||||
$text = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", ' $2 ', $text);
|
||||
$text = preg_replace("/\[img.*?\[\/img\]/ism", ' ', $text);
|
||||
|
||||
// Remove attachment
|
||||
$text = self::removeAttachment($text);
|
||||
|
||||
$naked_text = HTML::toPlaintext(self::convert($text, false, 0, true), 0, !$keep_urls);
|
||||
|
||||
return $naked_text;
|
||||
}
|
||||
|
||||
private static function proxyUrl($image, $simplehtml = self::INTERNAL)
|
||||
private static function proxyUrl($image, $simplehtml = self::INTERNAL, $uriid = 0, $size = '')
|
||||
{
|
||||
// Only send proxied pictures to API and for internal display
|
||||
if (in_array($simplehtml, [self::INTERNAL, self::API])) {
|
||||
return ProxyUtils::proxifyUrl($image);
|
||||
} else {
|
||||
if (!in_array($simplehtml, [self::INTERNAL, self::API])) {
|
||||
return $image;
|
||||
} elseif ($uriid) {
|
||||
return Post\Link::getByLink($uriid, $image, $size);
|
||||
} else {
|
||||
return ProxyUtils::proxifyUrl($image, $size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,10 +618,11 @@ class BBCode
|
|||
* @param integer $simplehtml
|
||||
* @param bool $tryoembed
|
||||
* @param array $data
|
||||
* @param int $uriid
|
||||
* @return string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function convertAttachment($text, $simplehtml = self::INTERNAL, $tryoembed = true, array $data = [])
|
||||
public static function convertAttachment($text, $simplehtml = self::INTERNAL, $tryoembed = true, array $data = [], $uriid = 0)
|
||||
{
|
||||
$data = $data ?: self::getAttachmentData($text);
|
||||
if (empty($data) || empty($data['url'])) {
|
||||
|
@ -648,12 +659,12 @@ class BBCode
|
|||
|
||||
if (!empty($data['title']) && !empty($data['url'])) {
|
||||
if (!empty($data['image']) && empty($data['text']) && ($data['type'] == 'photo')) {
|
||||
$return .= sprintf('<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data['url'], self::proxyUrl($data['image'], $simplehtml), $data['title']);
|
||||
$return .= sprintf('<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data['url'], self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title']);
|
||||
} else {
|
||||
if (!empty($data['image'])) {
|
||||
$return .= sprintf('<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br>', $data['url'], self::proxyUrl($data['image'], $simplehtml), $data['title']);
|
||||
$return .= sprintf('<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br>', $data['url'], self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title']);
|
||||
} elseif (!empty($data['preview'])) {
|
||||
$return .= sprintf('<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br>', $data['url'], self::proxyUrl($data['preview'], $simplehtml), $data['title']);
|
||||
$return .= sprintf('<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br>', $data['url'], self::proxyUrl($data['preview'], $simplehtml, $uriid), $data['title']);
|
||||
}
|
||||
$return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
|
||||
}
|
||||
|
@ -929,7 +940,7 @@ class BBCode
|
|||
return ['body' => $new_body, 'images' => $saved_image];
|
||||
}
|
||||
|
||||
private static function interpolateSavedImagesIntoItemBody($body, array $images)
|
||||
private static function interpolateSavedImagesIntoItemBody($uriid, $body, array $images)
|
||||
{
|
||||
$newbody = $body;
|
||||
|
||||
|
@ -939,7 +950,7 @@ class BBCode
|
|||
// it loops over the array starting from the first element and going sequentially
|
||||
// to the last element
|
||||
$newbody = str_replace('[$#saved_image' . $cnt . '#$]',
|
||||
'<img src="' . self::proxyUrl($image) . '" alt="' . DI::l10n()->t('Image/photo') . '" />', $newbody);
|
||||
'<img src="' . self::proxyUrl($image, self::INTERNAL, $uriid) . '" alt="' . DI::l10n()->t('Image/photo') . '" />', $newbody);
|
||||
$cnt++;
|
||||
}
|
||||
|
||||
|
@ -954,7 +965,7 @@ class BBCode
|
|||
public static function fetchShareAttributes($text)
|
||||
{
|
||||
// See Issue https://github.com/friendica/friendica/issues/10454
|
||||
// Hashtags in usernames are expanded to links. This here is a quick fix.
|
||||
// Hashtags in usernames are expanded to links. This here is a quick fix.
|
||||
$text = preg_replace('/([@!#])\[url\=.*?\](.*?)\[\/url\]/ism', '$1$2', $text);
|
||||
|
||||
$attributes = [];
|
||||
|
@ -989,11 +1000,11 @@ class BBCode
|
|||
* @param callable $callback
|
||||
* @return string The BBCode string with all [share] blocks replaced
|
||||
*/
|
||||
public static function convertShare($text, callable $callback)
|
||||
public static function convertShare($text, callable $callback, int $uriid = 0)
|
||||
{
|
||||
$return = preg_replace_callback(
|
||||
"/(.*?)\[share(.*?)\](.*)\[\/share\]/ism",
|
||||
function ($match) use ($callback) {
|
||||
function ($match) use ($callback, $uriid) {
|
||||
$attribute_string = $match[2];
|
||||
$attributes = [];
|
||||
foreach (['author', 'profile', 'avatar', 'link', 'posted', 'guid'] as $field) {
|
||||
|
@ -1012,7 +1023,7 @@ class BBCode
|
|||
if (!empty($author_contact['id'])) {
|
||||
$attributes['avatar'] = Contact::getAvatarUrlForId($author_contact['id'], ProxyUtils::SIZE_THUMB);
|
||||
} elseif ($attributes['avatar']) {
|
||||
$attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], false, ProxyUtils::SIZE_THUMB);
|
||||
$attributes['avatar'] = self::proxyUrl($attributes['avatar'], self::INTERNAL, $uriid, ProxyUtils::SIZE_THUMB);
|
||||
}
|
||||
|
||||
$content = preg_replace(Strings::autoLinkRegEx(), '<a href="$1">$1</a>', $match[3]);
|
||||
|
@ -1252,6 +1263,37 @@ class BBCode
|
|||
return $bbcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a BBCode message for a given URI-ID to a HTML message
|
||||
*
|
||||
* BBcode 2 HTML was written by WAY2WEB.net
|
||||
* extended to work with Mistpark/Friendica - Mike Macgirvin
|
||||
*
|
||||
* Simple HTML values meaning:
|
||||
* - 0: Friendica display
|
||||
* - 1: Unused
|
||||
* - 2: Used for Windows Phone push, Friendica API
|
||||
* - 3: Used before converting to Markdown in bb2diaspora.php
|
||||
* - 4: Used for WordPress, Libertree (before Markdown), pump.io and tumblr
|
||||
* - 5: Unused
|
||||
* - 6: Unused
|
||||
* - 7: Used for dfrn, OStatus
|
||||
* - 8: Used for Twitter, WP backlink text setting
|
||||
* - 9: ActivityPub
|
||||
*
|
||||
* @param int $uriid
|
||||
* @param string $text
|
||||
* @param int $simple_html
|
||||
* @return string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function convertForUriId(int $uriid = 0, string $text = null, int $simple_html = self::INTERNAL)
|
||||
{
|
||||
$try_oembed = ($simple_html == self::INTERNAL);
|
||||
|
||||
return self::convert($text, $try_oembed, $simple_html, false, $uriid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a BBCode message to HTML message
|
||||
*
|
||||
|
@ -1274,10 +1316,11 @@ class BBCode
|
|||
* @param bool $try_oembed
|
||||
* @param int $simple_html
|
||||
* @param bool $for_plaintext
|
||||
* @param int $uriid
|
||||
* @return string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function convert(string $text = null, $try_oembed = true, $simple_html = self::INTERNAL, $for_plaintext = false)
|
||||
public static function convert(string $text = null, $try_oembed = true, $simple_html = self::INTERNAL, $for_plaintext = false, $uriid = 0)
|
||||
{
|
||||
// Accounting for null default column values
|
||||
if (is_null($text) || $text === '') {
|
||||
|
@ -1288,8 +1331,8 @@ class BBCode
|
|||
|
||||
$a = DI::app();
|
||||
|
||||
$text = self::performWithEscapedTags($text, ['code'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $a) {
|
||||
$text = self::performWithEscapedTags($text, ['noparse', 'nobb', 'pre'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $a) {
|
||||
$text = self::performWithEscapedTags($text, ['code'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $a, $uriid) {
|
||||
$text = self::performWithEscapedTags($text, ['noparse', 'nobb', 'pre'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $a, $uriid) {
|
||||
/*
|
||||
* preg_match_callback function to replace potential Oembed tags with Oembed content
|
||||
*
|
||||
|
@ -1398,7 +1441,7 @@ class BBCode
|
|||
} elseif (!in_array($simple_html, [self::INTERNAL, self::EXTERNAL, self::CONNECTORS])) {
|
||||
$text = self::removeAttachment($text, true);
|
||||
} else {
|
||||
$text = self::convertAttachment($text, $simple_html, $try_oembed);
|
||||
$text = self::convertAttachment($text, $simple_html, $try_oembed, [], $uriid);
|
||||
}
|
||||
|
||||
$nosmile = strpos($text, '[nosmile]') !== false;
|
||||
|
@ -1573,12 +1616,12 @@ class BBCode
|
|||
// [img=widthxheight]image source[/img]
|
||||
$text = preg_replace_callback(
|
||||
"/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism",
|
||||
function ($matches) use ($simple_html) {
|
||||
function ($matches) use ($simple_html, $uriid) {
|
||||
if (strpos($matches[3], "data:image/") === 0) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
$matches[3] = self::proxyUrl($matches[3], $simple_html);
|
||||
$matches[3] = self::proxyUrl($matches[3], $simple_html, $uriid);
|
||||
return "[img=" . $matches[1] . "x" . $matches[2] . "]" . $matches[3] . "[/img]";
|
||||
},
|
||||
$text
|
||||
|
@ -1588,8 +1631,8 @@ class BBCode
|
|||
$text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" >', $text);
|
||||
|
||||
$text = preg_replace_callback("/\[img\=(.*?)\](.*?)\[\/img\]/ism",
|
||||
function ($matches) use ($simple_html) {
|
||||
$matches[1] = self::proxyUrl($matches[1], $simple_html);
|
||||
function ($matches) use ($simple_html, $uriid) {
|
||||
$matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid);
|
||||
$matches[2] = htmlspecialchars($matches[2], ENT_COMPAT);
|
||||
return '<img src="' . $matches[1] . '" alt="' . $matches[2] . '" title="' . $matches[2] . '">';
|
||||
},
|
||||
|
@ -1599,12 +1642,12 @@ class BBCode
|
|||
// [img]pathtoimage[/img]
|
||||
$text = preg_replace_callback(
|
||||
"/\[img\](.*?)\[\/img\]/ism",
|
||||
function ($matches) use ($simple_html) {
|
||||
function ($matches) use ($simple_html, $uriid) {
|
||||
if (strpos($matches[1], "data:image/") === 0) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
$matches[1] = self::proxyUrl($matches[1], $simple_html);
|
||||
$matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid);
|
||||
return "[img]" . $matches[1] . "[/img]";
|
||||
},
|
||||
$text
|
||||
|
@ -1686,7 +1729,7 @@ class BBCode
|
|||
// start which is always required). Allow desc with a missing summary for compatibility.
|
||||
|
||||
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
|
||||
$sub = Event::getHTML($ev, $simple_html);
|
||||
$sub = Event::getHTML($ev, $simple_html, $uriid);
|
||||
|
||||
$text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism", '', $text);
|
||||
$text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism", '', $text);
|
||||
|
@ -1849,10 +1892,10 @@ class BBCode
|
|||
$text,
|
||||
function (array $attributes, array $author_contact, $content, $is_quote_share) use ($simple_html) {
|
||||
return self::convertShareCallback($attributes, $author_contact, $content, $is_quote_share, $simple_html);
|
||||
}
|
||||
}, $uriid
|
||||
);
|
||||
|
||||
$text = self::interpolateSavedImagesIntoItemBody($text, $saved_image);
|
||||
$text = self::interpolateSavedImagesIntoItemBody($uriid, $text, $saved_image);
|
||||
|
||||
return $text;
|
||||
}); // Escaped noparse, nobb, pre
|
||||
|
@ -2126,8 +2169,8 @@ class BBCode
|
|||
/**
|
||||
* Expand tags to URLs
|
||||
*
|
||||
* @param string $body
|
||||
* @return string body with expanded tags
|
||||
* @param string $body
|
||||
* @return string body with expanded tags
|
||||
*/
|
||||
public static function expandTags(string $body)
|
||||
{
|
||||
|
|
|
@ -329,8 +329,6 @@ class System
|
|||
function info($s)
|
||||
function is_site_admin()
|
||||
function get_temppath()
|
||||
function get_cachefile($file, $writemode = true)
|
||||
function get_itemcachepath()
|
||||
function get_spoolpath()
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -349,6 +349,12 @@ class APContact
|
|||
$apcontact['alias'] = null;
|
||||
}
|
||||
|
||||
if (empty($apcontact['uuid'])) {
|
||||
$apcontact['uri-id'] = ItemURI::getIdByURI($apcontact['url']);
|
||||
} else {
|
||||
$apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['uri'], 'guid' => $apcontact['uuid']]);
|
||||
}
|
||||
|
||||
$apcontact['updated'] = DateTimeFormat::utcNow();
|
||||
|
||||
// We delete the old entry when the URL is changed
|
||||
|
|
|
@ -185,6 +185,8 @@ class Contact
|
|||
$fields['gsid'] = GServer::getID($fields['baseurl'], true);
|
||||
}
|
||||
|
||||
$fields['uri-id'] = ItemURI::getIdByURI($fields['url']);
|
||||
|
||||
if (empty($fields['created'])) {
|
||||
$fields['created'] = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
@ -1497,67 +1499,46 @@ class Contact
|
|||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
private static function getAvatarPath(array $contact, string $field, string $size, string $avatar, $no_update = false)
|
||||
private static function getAvatarPath(array $contact, string $size, $no_update = false)
|
||||
{
|
||||
if (!empty($contact)) {
|
||||
$contact = self::checkAvatarCacheByArray($contact, $no_update);
|
||||
if (!empty($contact['id'])) {
|
||||
return self::getAvatarUrlForId($contact['id'], $size, $contact['updated'] ?? '');
|
||||
} elseif (!empty($contact[$field])) {
|
||||
return $contact[$field];
|
||||
} elseif (!empty($contact['avatar'])) {
|
||||
$avatar = $contact['avatar'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($avatar)) {
|
||||
$avatar = self::getDefaultAvatar([], $size);
|
||||
}
|
||||
|
||||
if (Proxy::isLocalImage($avatar)) {
|
||||
return $avatar;
|
||||
} else {
|
||||
return Proxy::proxifyUrl($avatar, false, $size);
|
||||
}
|
||||
$contact = self::checkAvatarCacheByArray($contact, $no_update);
|
||||
return self::getAvatarUrlForId($contact['id'], $size, $contact['updated'] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the photo path for a given contact array
|
||||
*
|
||||
* @param array $contact Contact array
|
||||
* @param string $avatar Avatar path that is displayed when no photo had been found
|
||||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
public static function getPhoto(array $contact, string $avatar = '', bool $no_update = false)
|
||||
public static function getPhoto(array $contact, bool $no_update = false)
|
||||
{
|
||||
return self::getAvatarPath($contact, 'photo', Proxy::SIZE_SMALL, $avatar, $no_update);
|
||||
return self::getAvatarPath($contact, Proxy::SIZE_SMALL, $no_update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the photo path (thumb size) for a given contact array
|
||||
*
|
||||
* @param array $contact Contact array
|
||||
* @param string $avatar Avatar path that is displayed when no photo had been found
|
||||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
public static function getThumb(array $contact, string $avatar = '', bool $no_update = false)
|
||||
public static function getThumb(array $contact, bool $no_update = false)
|
||||
{
|
||||
return self::getAvatarPath($contact, 'thumb', Proxy::SIZE_THUMB, $avatar, $no_update);
|
||||
return self::getAvatarPath($contact, Proxy::SIZE_THUMB, $no_update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the photo path (micro size) for a given contact array
|
||||
*
|
||||
* @param array $contact Contact array
|
||||
* @param string $avatar Avatar path that is displayed when no photo had been found
|
||||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
public static function getMicro(array $contact, string $avatar = '', bool $no_update = false)
|
||||
public static function getMicro(array $contact, bool $no_update = false)
|
||||
{
|
||||
return self::getAvatarPath($contact, 'micro', Proxy::SIZE_MICRO, $avatar, $no_update);
|
||||
return self::getAvatarPath($contact, Proxy::SIZE_MICRO, $no_update);
|
||||
}
|
||||
|
||||
/**
|
||||
|