notification and update issues

This commit is contained in:
nobody 2021-11-16 17:58:45 -08:00
parent 762fb66128
commit b73d84a946
7 changed files with 41 additions and 43 deletions

View file

@ -147,7 +147,7 @@ class Enotify {
$itemlink = z_root() . '/display/' . gen_link_id($params['item']['mid']);
}
if (in_array(intval($params['type']), [ NOTIFY_COMMENT, NOTIFY_RESHARE ] ) {
if (in_array(intval($params['type']), [ NOTIFY_COMMENT, NOTIFY_RESHARE ] )) {
// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
$moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false);

View file

@ -223,6 +223,7 @@ class Channel extends Controller {
if ($this->loading && ! $mid) {
$_SESSION['loadtime_channel'] = datetime_convert();
if ($is_owner) {
PConfig::Set(local_channel(),'system','loadtime_channel',$_SESSION['loadtime_channel']);
@ -360,7 +361,6 @@ class Channel extends Controller {
}
if (($this->updating) && (! $this->loading)) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal_update
AND item_wall = 1 $simple_update $sql_extra limit 1",
@ -379,7 +379,6 @@ class Channel extends Controller {
intval(App::$profile['profile_uid'])
);
}
}
else {

View file

@ -52,7 +52,9 @@ class Ping extends Controller {
$vnotify = false;
$evdays = 3;
$my_activity = 0;
$item_normal = item_normal();
if (local_channel()) {
@ -154,20 +156,25 @@ class Ping extends Controller {
$loadtime = get_loadtime('pubstream');
if ($notify_pubs) {
$pubs = q("SELECT count(id) as total from item
$pubs = q("SELECT id, author_xchan from item
WHERE uid = %d
AND author_xchan != '%s'
AND created > '%s'
$seenstr
$item_normal
$sql_extra",
intval($sys['channel_id']),
dbesc(get_observer_hash()),
dbesc($loadtime)
);
if ($pubs) {
$result['pubs'] = intval($pubs[0]['total']);
foreach($pubs as $p) {
if ($p['author_xchan'] === get_observer_hash()) {
$my_activity ++;
}
else {
$result['pubs'] ++;
}
}
}
}
@ -545,7 +552,8 @@ class Ping extends Controller {
/**
* Normal ping - just the counts, no detail
*/
if ($vnotify & VNOTIFY_SYSTEM) {
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_channel())
@ -573,15 +581,13 @@ class Ping extends Controller {
if ($vnotify & VNOTIFY_NETWORK) {
$loadtime = get_loadtime('stream');
$r = q("SELECT id FROM item
$r = q("SELECT id, author_xchan FROM item
WHERE uid = %d and changed > '%s'
$seenstr
$item_normal
$sql_extra
AND author_xchan != '%s'",
$sql_extra ",
intval(local_channel()),
dbesc($loadtime),
dbesc($ob_hash)
dbesc($loadtime)
);
if($r) {
@ -589,7 +595,12 @@ class Ping extends Controller {
call_hooks('network_ping', $arr);
foreach ($r as $it) {
$result['stream'] ++;
if ($it['author_xchan'] === $ob_hash) {
$my_activity ++;
}
else {
$result['stream'] ++;
}
}
}
}
@ -599,20 +610,23 @@ class Ping extends Controller {
if ($vnotify & VNOTIFY_CHANNEL) {
$loadtime = get_loadtime('channel');
$r = q("SELECT id FROM item
$r = q("SELECT id, author_xchan FROM item
WHERE item_wall = 1 and uid = %d and changed > '%s'
$seenstr
$item_normal
$sql_extra
AND author_xchan != '%s'",
$sql_extra ",
intval(local_channel()),
dbesc($loadtime),
dbesc($ob_hash)
dbesc($loadtime)
);
if ($r) {
foreach ($r as $it) {
$result['home'] ++;
if ($it['author_xchan'] === $ob_hash) {
$my_activity ++;
}
else {
$result['home'] ++;
}
}
}
}
@ -752,9 +766,9 @@ class Ping extends Controller {
// Mark all of the stream notifications seen if all three of them are caught up.
// This also resets the pconfig storage for items_seen
if (! (intval($result['home']) + intval($result['stream']) + intval($result['pubs']))) {
if ((! $my_activity) && (! (intval($result['home']) + intval($result['stream']) + intval($result['pubs'])))) {
PConfig::Delete(local_channel(),'system','seen_items');
$_SESSION['loadtime_channel'] = datetime_convert();
$_SESSION['loadtime_stream'] = datetime_convert();
$_SESSION['loadtime_pubstream'] = datetime_convert();

View file

@ -2419,17 +2419,7 @@ function item_update_parent_commented($item) {
$update_parent = true;
$update_changed = true;
$c = channelx_by_n($item['uid']);
// don't modify the changed time on the parent if we commented on it.
// This messes up the notification system, which ignores changes made by us
if ($c && $item['author_xchan'] === $c['channel_hash']) {
$update_changed = false;
}
// update the commented timestamp on the parent
// - unless this is a moderated comment or a potential clone of an older item
// which we don't wish to bring to the surface. As the queue only holds deliveries
@ -2448,16 +2438,11 @@ function item_update_parent_commented($item) {
intval($item['uid'])
);
q("UPDATE item set commented = '%s' WHERE id = %d",
q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d",
dbesc(($z) ? $z[0]['commented'] : datetime_convert()),
dbesc(datetime_convrt()),
intval($item['parent'])
);
if ($update_changed) {
q("UPDATE item set changed = '%s' WHERE id = %d",
dbesc(datetime_convert()),
intval($item['parent'])
);
}
}
}

View file

@ -26,7 +26,7 @@ class JSalmon:
def verify(x,key):
if x['signed'] != True:
return false
return False
signed_data = re.sub(r'\s+','', x['data'] + "." + base64urlnopad_encode(x['data_type'].encode("utf-8")) + "." + base64urlnopad_encode(x['encoding'].encode("utf-8")) + "." + base64urlnopad_encode(x['alg'].encode("utf-8")))

View file

@ -20,7 +20,7 @@ def base64urlnopad_decode(data: str) -> bytes:
return base64.urlsafe_b64decode(data)
def generate_rsa_keypair() -> (str, str):
def generate_rsa_keypair() -> tuple(str, str):
key = rsa.generate_private_key(
public_exponent = 65537,
key_size = 4096,

View file

@ -1028,7 +1028,7 @@ function liveUpdate(notify_id) {
let expanded = $('.comment-edit-text.expanded');
if(typeof profile_uid === 'undefined') profile_uid = false; /* Should probably be unified with channelId defined in head.tpl */
if(typeof profile_uid === 'undefined') profile_uid = false;
if((src === null) || (! profile_uid)) { $('.like-rotator').hide(); return; }