mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
Merge branch 'dev' of codeberg.org:streams/streams into dev
This commit is contained in:
commit
24f1df1802
7 changed files with 66 additions and 21 deletions
|
@ -2236,16 +2236,17 @@ class Activity
|
|||
}
|
||||
|
||||
|
||||
public static function unfollow($channel, $act)
|
||||
public static function unfollowActor($channel, $actor)
|
||||
{
|
||||
/* actor is unfollowing $channel */
|
||||
if (! $actor) {
|
||||
return;
|
||||
}
|
||||
$actorId = is_string($actor) ? $actor : $actor['id'];
|
||||
|
||||
$person_obj = $act->actor;
|
||||
|
||||
if (is_array($person_obj)) {
|
||||
if ($actorId) {
|
||||
$r = q(
|
||||
"select * from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d limit 1",
|
||||
dbesc($person_obj['id']),
|
||||
dbesc($actorId),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if ($r) {
|
||||
|
|
|
@ -153,7 +153,7 @@ class Channel extends Controller
|
|||
http_status_exit(403, 'Permission denied');
|
||||
}
|
||||
|
||||
as_return_and_die(Activity::encode_person($channel, true, true), $channel);
|
||||
as_return_and_die(Activity::encode_person($channel, true, true), $channel, '',false);
|
||||
}
|
||||
|
||||
// handle zot6 channel discovery
|
||||
|
|
|
@ -375,6 +375,12 @@ class Inbox extends Controller
|
|||
break;
|
||||
|
||||
case 'Reject':
|
||||
if (is_array($AS->obj) && array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Follow'
|
||||
&& isset($AS->obj['object'])) {
|
||||
// do unfollow activity
|
||||
Activity::unfollowActor($channel, $AS->obj['object']);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -424,10 +430,27 @@ class Inbox extends Controller
|
|||
}
|
||||
}
|
||||
if ($AS->type === 'Undo') {
|
||||
if ($AS->obj && is_array($AS->obj) && array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Follow') {
|
||||
// do unfollow activity
|
||||
Activity::unfollow($channel, $AS);
|
||||
return true;
|
||||
if ($AS->obj && is_array($AS->obj)) {
|
||||
if (array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Follow') {
|
||||
// do unfollow activity
|
||||
Activity::unfollowActor($channel, $AS->actor['id']);
|
||||
return true;
|
||||
}
|
||||
if (array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Accept') {
|
||||
// do a deep dive
|
||||
if (isset($AS->obj['object'])) {
|
||||
$originalActivity = $AS->obj['object'];
|
||||
if (is_string($AS->obj['object'])) {
|
||||
$originalActivity = Activity::fetch($AS->obj['object']);
|
||||
}
|
||||
if ($originalActivity && isset($originalActivity['type']) && $originalActivity['type'] === 'Follow'
|
||||
&& isset($originalActivity['object'])) {
|
||||
$person = is_string($originalActivity['object']) ? $originalActivity['object'] : $originalActivity['object']['id'];
|
||||
Activity::unfollowActor($channel, $person);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($AS->type === 'Accept') {
|
||||
|
@ -438,7 +461,7 @@ class Inbox extends Controller
|
|||
if ($AS->type === 'Leave') {
|
||||
if ($AS->obj && is_array($AS->obj) && array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Group') {
|
||||
// do unfollow activity
|
||||
Activity::unfollow($channel, $AS);
|
||||
Activity::unfollowActor($channel, $AS->obj['id']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,10 +327,27 @@ class Outbox extends Controller
|
|||
}
|
||||
}
|
||||
if ($AS->type === 'Undo') {
|
||||
if ($AS->obj && is_array($AS->obj) && array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Follow') {
|
||||
// do unfollow activity
|
||||
Activity::unfollow($channel, $AS);
|
||||
return true;
|
||||
if ($AS->obj && is_array($AS->obj)) {
|
||||
if (array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Follow') {
|
||||
// do unfollow activity
|
||||
Activity::unfollowActor($channel, $AS->actor['id']);
|
||||
return true;
|
||||
}
|
||||
if (array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Accept') {
|
||||
// do a deep dive
|
||||
if (isset($AS->obj['object'])) {
|
||||
$originalActivity = $AS->obj['object'];
|
||||
if (is_string($AS->obj['object'])) {
|
||||
$originalActivity = Activity::fetch($AS->obj['object']);
|
||||
}
|
||||
if ($originalActivity && isset($originalActivity['type']) && $originalActivity['type'] === 'Follow'
|
||||
&& isset($originalActivity['object'])) {
|
||||
$person = is_string($originalActivity['object']) ? $originalActivity['object'] : $originalActivity['object']['id'];
|
||||
Activity::unfollowActor($channel, $person);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($AS->type === 'Accept') {
|
||||
|
@ -341,7 +358,7 @@ class Outbox extends Controller
|
|||
if ($AS->type === 'Leave') {
|
||||
if ($AS->obj && is_array($AS->obj) && array_key_exists('type', $AS->obj) && $AS->obj['type'] === 'Group') {
|
||||
// do unfollow activity
|
||||
Activity::unfollow($channel, $AS);
|
||||
Activity::unfollowActor($channel, $AS->obj['id']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ The ActivityPub implementation in this software strives to be compliant to the c
|
|||
|
||||
Supported activities:
|
||||
|
||||
- `Follow(Actor)`, `Accept(Follow)`, `Reject(Follow)`, `Undo(Follow)`.
|
||||
- `Follow(Actor)`, `Accept(Follow)`, `Reject(Follow)`, `Undo(Follow)`, `Undo(Accept/Follow)`.
|
||||
- `Join(Group)`, `Accept(Join)`, `Reject(Join)`, `Leave(Group)`
|
||||
- `Create(Note|Article|Question|Page|Document|Image|Video|Audio)`, `Update(Note|Article|Question|Page|Document|Image|Video|Audio)`, `Delete(Note|Article|Question|Page|Document|Image|Video|Audio)`.
|
||||
- `Like(Note|Article|Question|Page|Document|Image|Video|Audio)`, `Undo(Like)`.
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
An open source fediverse server with a long history of innovation. See [FEATURES](https://codeberg.org/streams/streams/src/branch/dev/FEATURES.md).
|
||||
|
||||
This software is dedicated to the public domain to the extent permissible by law and is not associated with any consumer brand or product.
|
||||
The software supports a wide range of online behaviour, from personal communications with closed media access - all the way to fully public broadcasting. The default settings tend to favor personal and private use. Adjust as desired.
|
||||
|
||||
This repository uses a community-driven model. This means that there are no dedicated developers working on new features or bug fixes or translations or documentation. Instead, it relies on the contributed efforts of those that choose to use it.
|
||||
|
||||
This software is dedicated to the public domain to the extent permissible by law and is not associated with any consumer brand or product.
|
||||
|
||||
A fediverse support group exists at
|
||||
https://fediversity.site/channel/streams
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ function json_return_and_die($x, $content_type = 'application/json', $debug = fa
|
|||
killme();
|
||||
}
|
||||
|
||||
function as_return_and_die($obj, $channel, $contextType = null)
|
||||
function as_return_and_die($obj, $channel, $contextType = null, $ldsign = true)
|
||||
{
|
||||
|
||||
if (! is_array($obj)) {
|
||||
|
@ -52,7 +52,9 @@ function as_return_and_die($obj, $channel, $contextType = null)
|
|||
|
||||
$headers = [];
|
||||
$headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
|
||||
$data['signature'] = LDSignatures::sign($data, $channel);
|
||||
if ($ldsign) {
|
||||
$data['signature'] = LDSignatures::sign($data, $channel);
|
||||
}
|
||||
$json = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||
logger('data: ' . jindent($json), LOGGER_DATA);
|
||||
$headers['Date'] = datetime_convert('UTC', 'UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T');
|
||||
|
|
Loading…
Reference in a new issue