Merge remote-tracking branch 'upstream/develop' into dbclean
This commit is contained in:
commit
4bf425de5d
56
database.sql
56
database.sql
|
@ -274,29 +274,6 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
|
|||
UNIQUE INDEX `url` (`url`(190))
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE ffinder
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `ffinder` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`uid` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`cid` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`fid` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE fserver
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `fserver` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`server` varchar(255) NOT NULL DEFAULT '',
|
||||
`posturl` varchar(255) NOT NULL DEFAULT '',
|
||||
`key` text,
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `server` (`server`(32))
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE fsuggest
|
||||
--
|
||||
|
@ -558,22 +535,6 @@ CREATE TABLE IF NOT EXISTS `item` (
|
|||
INDEX `uid_ownerlink` (`uid`,`owner-link`(190))
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE item_id
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `item_id` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`iid` int(11) NOT NULL DEFAULT 0,
|
||||
`uid` int(11) NOT NULL DEFAULT 0,
|
||||
`sid` varchar(255) NOT NULL DEFAULT '',
|
||||
`service` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid` (`uid`),
|
||||
INDEX `sid` (`sid`(32)),
|
||||
INDEX `service` (`service`(32)),
|
||||
INDEX `iid` (`iid`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE locks
|
||||
--
|
||||
|
@ -948,23 +909,6 @@ CREATE TABLE IF NOT EXISTS `sign` (
|
|||
UNIQUE INDEX `iid` (`iid`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE spam
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `spam` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`uid` int(11) NOT NULL DEFAULT 0,
|
||||
`spam` int(11) NOT NULL DEFAULT 0,
|
||||
`ham` int(11) NOT NULL DEFAULT 0,
|
||||
`term` varchar(255) NOT NULL DEFAULT '',
|
||||
`date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX `uid` (`uid`),
|
||||
INDEX `spam` (`spam`),
|
||||
INDEX `ham` (`ham`),
|
||||
INDEX `term` (`term`(32))
|
||||
) DEFAULT COLLATE utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- TABLE term
|
||||
--
|
||||
|
|
|
@ -888,29 +888,6 @@ function db_definition() {
|
|||
"url" => array("UNIQUE", "url(190)"),
|
||||
)
|
||||
);
|
||||
$database["ffinder"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||
"cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
|
||||
"fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
)
|
||||
);
|
||||
$database["fserver"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"key" => array("type" => "text"),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"server" => array("server(32)"),
|
||||
)
|
||||
);
|
||||
$database["fsuggest"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
|
@ -1172,22 +1149,6 @@ function db_definition() {
|
|||
"uid_ownerlink" => array("uid","owner-link(190)"),
|
||||
)
|
||||
);
|
||||
$database["item_id"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
|
||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||
"sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"uid" => array("uid"),
|
||||
"sid" => array("sid(32)"),
|
||||
"service" => array("service(32)"),
|
||||
"iid" => array("iid"),
|
||||
)
|
||||
);
|
||||
$database["locks"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
|
@ -1562,23 +1523,6 @@ function db_definition() {
|
|||
"iid" => array("UNIQUE", "iid"),
|
||||
)
|
||||
);
|
||||
$database["spam"] = array(
|
||||
"fields" => array(
|
||||
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
|
||||
"spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
|
||||
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||
"date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
|
||||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"uid" => array("uid"),
|
||||
"spam" => array("spam"),
|
||||
"ham" => array("ham"),
|
||||
"term" => array("term(32)"),
|
||||
)
|
||||
);
|
||||
$database["term"] = array(
|
||||
"fields" => array(
|
||||
"tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
function fcontact_store($url,$name,$photo) {
|
||||
|
||||
$nurl = str_replace(array('https:','//www.'), array('http:','//'), $url);
|
||||
|
||||
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
|
||||
dbesc($nurl)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r))
|
||||
return $r[0]['id'];
|
||||
|
||||
$r = dba::insert('fcontact', array('url' => $nurl, 'name' => $name, 'photo' => $photo));
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
|
||||
dbesc($nurl)
|
||||
);
|
||||
if (DBM::is_result($r))
|
||||
return $r[0]['id'];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function ffinder_store($uid,$cid,$fid) {
|
||||
$r = dba::insert('ffinder', array('uid' => $uid, 'cid' => $cid, 'fid' => $fid));
|
||||
return $r;
|
||||
}
|
||||
|
|
@ -2233,7 +2233,6 @@ function drop_item($id, $interactive = true) {
|
|||
|
||||
// Now delete them
|
||||
if ($parentid != "") {
|
||||
$r = q("DELETE FROM `item_id` WHERE `iid` IN (%s)", dbesc($parentid));
|
||||
$r = q("DELETE FROM `sign` WHERE `iid` IN (%s)", dbesc($parentid));
|
||||
}
|
||||
|
||||
|
|
|
@ -153,14 +153,13 @@ Class Cron {
|
|||
: ''
|
||||
);
|
||||
|
||||
$contacts = q("SELECT `contact`.`id`, `contact`.`nick`, `contact`.`name`, `contact`.`network`,
|
||||
`contact`.`last-update`, `contact`.`priority`, `contact`.`subhub`
|
||||
$contacts = q("SELECT `contact`.`id`, `contact`.`nick`, `contact`.`name`, `contact`.`network`, `contact`.`archive`,
|
||||
`contact`.`last-update`, `contact`.`priority`, `contact`.`rel`, `contact`.`subhub`
|
||||
FROM `user`
|
||||
STRAIGHT_JOIN `contact`
|
||||
ON `contact`.`uid` = `user`.`uid` AND `contact`.`poll` != ''
|
||||
AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s') $sql_extra
|
||||
AND NOT `contact`.`self` AND NOT `contact`.`blocked` AND NOT `contact`.`readonly`
|
||||
AND NOT `contact`.`archive`
|
||||
AND NOT `contact`.`self` AND NOT `contact`.`blocked`
|
||||
WHERE NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql",
|
||||
dbesc(NETWORK_DFRN),
|
||||
dbesc(NETWORK_OSTATUS),
|
||||
|
@ -179,6 +178,7 @@ Class Cron {
|
|||
$contact['last-update'] = NULL_DATE;
|
||||
}
|
||||
|
||||
// Friendica and OStatus are checked once a day
|
||||
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS))) {
|
||||
$contact['priority'] = 2;
|
||||
}
|
||||
|
@ -191,7 +191,17 @@ Class Cron {
|
|||
* changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
|
||||
*/
|
||||
$poll_interval = Config::get('system', 'pushpoll_frequency');
|
||||
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
|
||||
$contact['priority'] = (!is_null($poll_interval) ? intval($poll_interval) : 3);
|
||||
}
|
||||
|
||||
// Check Diaspora contacts or followers once a week
|
||||
if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
||||
$contact['priority'] = 4;
|
||||
}
|
||||
|
||||
// Check archived contacts once a month
|
||||
if ($contact['archive']) {
|
||||
$contact['priority'] = 5;
|
||||
}
|
||||
|
||||
if (($contact['priority'] >= 0) && !$force) {
|
||||
|
@ -240,13 +250,16 @@ Class Cron {
|
|||
}
|
||||
}
|
||||
|
||||
logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact["nick"] . " " . $contact["name"]);
|
||||
|
||||
if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) {
|
||||
$priority = PRIORITY_MEDIUM;
|
||||
} elseif ($contact['archive']) {
|
||||
$priority = PRIORITY_NEGLIGIBLE;
|
||||
} else {
|
||||
$priority = PRIORITY_LOW;
|
||||
}
|
||||
|
||||
logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]);
|
||||
|
||||
Worker::add(array('priority' => $priority, 'dont_fork' => true), 'OnePoll', (int)$contact['id']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,27 +63,25 @@ Class OnePoll
|
|||
}
|
||||
}
|
||||
|
||||
// Diaspora users and followers we only check if they still exist.
|
||||
if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
||||
if (PortableContact::updateNeeded($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
|
||||
$last_updated = PortableContact::lastUpdated($contact["url"]);
|
||||
$updated = datetime_convert();
|
||||
if ($last_updated) {
|
||||
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
||||
// Diaspora users, archived users and followers are only checked if they still exist.
|
||||
if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
||||
$last_updated = PortableContact::lastUpdated($contact["url"]);
|
||||
$updated = datetime_convert();
|
||||
if ($last_updated) {
|
||||
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
||||
|
||||
// The last public item can be older than the last item we got
|
||||
if ($last_updated < $contact['last-item']) {
|
||||
$last_updated = $contact['last-item'];
|
||||
}
|
||||
|
||||
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
|
||||
self::updateContact($contact, $fields);
|
||||
Contact::unmarkForArchival($contact);
|
||||
} else {
|
||||
self::updateContact($contact, array('last-update' => $updated, 'failure_update' => $updated));
|
||||
Contact::markForArchival($contact);
|
||||
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
||||
// The last public item can be older than the last item we got
|
||||
if ($last_updated < $contact['last-item']) {
|
||||
$last_updated = $contact['last-item'];
|
||||
}
|
||||
|
||||
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
|
||||
self::updateContact($contact, $fields);
|
||||
Contact::unmarkForArchival($contact);
|
||||
} else {
|
||||
self::updateContact($contact, array('last-update' => $updated, 'failure_update' => $updated));
|
||||
Contact::markForArchival($contact);
|
||||
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user