Merge pull request #7828 from nupplaphil/task/move_enotify

Remove unnecessary code in "include/enotify"
This commit is contained in:
Hypolite Petovan 2019-11-09 16:48:26 -05:00 committed by GitHub
commit f2c31ef1c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 33 deletions

View File

@ -793,7 +793,6 @@ CREATE TABLE IF NOT EXISTS `manage` (
-- --
CREATE TABLE IF NOT EXISTS `notify` ( CREATE TABLE IF NOT EXISTS `notify` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID', `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`hash` varchar(64) NOT NULL DEFAULT '' COMMENT '',
`type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '', `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '', `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '', `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@ -810,7 +809,6 @@ CREATE TABLE IF NOT EXISTS `notify` (
`name_cache` tinytext COMMENT 'Cached bbcode parsing of name', `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
`msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg', `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `hash_uid` (`hash`,`uid`),
INDEX `seen_uid_date` (`seen`,`uid`,`date`), INDEX `seen_uid_date` (`seen`,`uid`,`date`),
INDEX `uid_date` (`uid`,`date`), INDEX `uid_date` (`uid`,`date`),
INDEX `uid_type_link` (`uid`,`type`,`link`(190)) INDEX `uid_type_link` (`uid`,`type`,`link`(190))

View File

@ -503,17 +503,9 @@ function notification($params)
if ($show_in_notification_page) { if ($show_in_notification_page) {
Logger::log("adding notification entry", Logger::DEBUG); Logger::log("adding notification entry", Logger::DEBUG);
do {
$dups = false;
$hash = Strings::getRandomHex();
if (DBA::exists('notify', ['hash' => $hash])) {
$dups = true;
}
} while ($dups == true);
/// @TODO One statement is enough /// @TODO One statement is enough
$datarray = []; $datarray = [];
$datarray['hash'] = $hash;
$datarray['name'] = $params['source_name']; $datarray['name'] = $params['source_name'];
$datarray['name_cache'] = strip_tags(BBCode::convert($params['source_name'])); $datarray['name_cache'] = strip_tags(BBCode::convert($params['source_name']));
$datarray['url'] = $params['source_link']; $datarray['url'] = $params['source_link'];
@ -536,7 +528,7 @@ function notification($params)
} }
// create notification entry in DB // create notification entry in DB
$fields = ['hash' => $datarray['hash'], 'name' => $datarray['name'], 'url' => $datarray['url'], $fields = ['name' => $datarray['name'], 'url' => $datarray['url'],
'photo' => $datarray['photo'], 'date' => $datarray['date'], 'uid' => $datarray['uid'], 'photo' => $datarray['photo'], 'date' => $datarray['date'], 'uid' => $datarray['uid'],
'link' => $datarray['link'], 'iid' => $datarray['iid'], 'parent' => $datarray['parent'], 'link' => $datarray['link'], 'iid' => $datarray['iid'], 'parent' => $datarray['parent'],
'type' => $datarray['type'], 'verb' => $datarray['verb'], 'otype' => $datarray['otype'], 'type' => $datarray['type'], 'verb' => $datarray['verb'], 'otype' => $datarray['otype'],
@ -545,26 +537,6 @@ function notification($params)
$notify_id = DBA::lastInsertId(); $notify_id = DBA::lastInsertId();
// we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
// After we've stored everything, look again to see if there are any duplicates and if so remove them
$p = q("SELECT `id` FROM `notify` WHERE `type` IN (%d, %d) AND `link` = '%s' AND `uid` = %d ORDER BY `id`",
intval(NOTIFY_TAGSELF),
intval(NOTIFY_COMMENT),
DBA::escape($params['link']),
intval($params['uid'])
);
if ($p && (count($p) > 1)) {
for ($d = 1; $d < count($p); $d ++) {
DBA::delete('notify', ['id' => $p[$d]['id']]);
}
// only continue on if we stored the first one
if ($notify_id != $p[0]['id']) {
L10n::popLang();
return false;
}
}
$itemlink = System::baseUrl().'/notify/view/'.$notify_id; $itemlink = System::baseUrl().'/notify/view/'.$notify_id;
$msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $itemlink]); $msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $itemlink]);
$msg_cache = format_notification_message($datarray['name_cache'], strip_tags(BBCode::convert($msg))); $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(BBCode::convert($msg)));

View File

@ -868,7 +868,6 @@ return [
"comment" => "notifications", "comment" => "notifications",
"fields" => [ "fields" => [
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
"hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
"type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""], "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
"name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
@ -887,7 +886,6 @@ return [
], ],
"indexes" => [ "indexes" => [
"PRIMARY" => ["id"], "PRIMARY" => ["id"],
"hash_uid" => ["hash", "uid"],
"seen_uid_date" => ["seen", "uid", "date"], "seen_uid_date" => ["seen", "uid", "date"],
"uid_date" => ["uid", "date"], "uid_date" => ["uid", "date"],
"uid_type_link" => ["uid", "type", "link(190)"], "uid_type_link" => ["uid", "type", "link(190)"],