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

This commit is contained in:
Mike Macgirvin 2023-10-25 21:03:36 +11:00
commit acc4a4d9e5
4 changed files with 46 additions and 24 deletions

View file

@ -210,6 +210,37 @@ class Inbox extends Controller
dbesc(basename(is_array($AS->obj['actor']) ? $AS->obj['actor']['id'] : $AS->obj['actor']))
);
}
// Now for the peertube lunacy
// Activity actor is viewing an object attributed to an actor and a group. It was sent to the public inbox.
// actor (aka $observer_hash) in this case is a system actor whom we have no relationship with, so do a deep dive
// and find out if we have anybody on this site that has a relationship with either of the obj->attributedTo entities.
// Then change the $observer_hash to that entity, so it won't get rejected by the receiver for being sent by an unknown actor.
// Don't know why they couldn't send the activity as one or both of these instead of the system actor. We don't really care
// what the system actor is viewing. We have no relationship with them at all.
// There is a flaw here if both attributedTo entities have followers on this site, but I think in practice
// they will normally follow the group and not the actor. Will deal with that paradox another day, probably by
// duplicating the payload and delivering to each.
elseif ($AS->type === 'View' && !empty($AS->obj['attributedTo']) && is_array($AS->obj['attributedTo'])) {
foreach ($AS->obj['attributedTo'] as $actor) {
if (!empty($actor['id'])) {
$tmp = q("SELECT * from channel where channel_id in
( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash
WHERE xchan_network = 'activitypub' and xchan_hash = '%s'
) and channel_removed = 0 ",
dbesc($actor['id'])
);
if ($tmp) {
$observer_hash = $actor['id'];
if ($channels) {
$channels = array_merge($channels, $tmp);
}
else {
$channels = $tmp;
}
}
}
}
}
else {
$collections = Activity::get_actor_collections($observer_hash);

View file

@ -111,12 +111,12 @@ $(document).ready(function() {
$(document).on('z:handleNetWorkNotificationsItems', function(e, obj) {
push_notification(
obj.notify_id,
obj.name,
$('<p>' + obj.message + '</p>').text(),
obj.b64mid
);
// push_notification(
// obj.name,
// $('<p>' + obj.message + '</p>').text(),
// obj.b64mid
// );
});
@ -548,9 +548,6 @@ function markRead(notifType) {
$('#nav-' + notifType + '-sub').removeClass('show');
sessionStorage.removeItem(notifType + '_notifications_cache');
sessionStorage.removeItem('notification_open');
if (notifType == 'notify') {
localStorage.removeItem('notified');
}
if(timer) clearTimeout(timer);
timer = setTimeout(updateInit,2000);
}
@ -677,7 +674,7 @@ function handleNotificationsItems(notifyType, data) {
notify_menu.html('');
$(data).each(function() {
if (notifyType == 'notify' || notifyType == 'moderate' || notifyType == 'intros') {
if (notifyType == 'notify') {
$(document).trigger('z:handleNetWorkNotificationsItems', this);
}
@ -1732,18 +1729,7 @@ function push_notification_request(e) {
}
}
function push_notification(id, title, body, b64mid) {
let delivered = localStorage.getItem("notified");
if (!delivered) {
delivered = [];
}
if (delivered.includes(id)) {
return;
}
delivered.push(id);
localStorage.setItem("notified", delivered);
function push_notification(title, body, b64mid) {
let options = {
body: body,
data: b64mid,

View file

@ -1,6 +1,6 @@
name: Fresh
description: 'A Fresh new look for Streams.'
version: 'Version: 0.8'
version: 'Version: 0.10'
credits: 'Development provided by: <a href="https://www.knthost.com/streams">K&T Host - (www.knthost.com)</a>'
author: 'K&T Host'
maintainer:

View file

@ -113,6 +113,11 @@ blockquote {
.item-highlight {
border-left: 0.2rem solid $action;
}
.alert-warning {
background: $warning;
color: #222;
border: none;
}
.text-black-50, .text-dark {
color: $font_color !important;
}
@ -146,7 +151,7 @@ fieldset:disabled .btn,
.btn-warning,
.btn-primary,
.btn-success {
color: $font_contrast_color;
color: $font_contrast_color !important;
}
.btn-primary {
background-color: $primary;