Bluesky: Tasks are now done by workers #1399

Merged
MrPetovan merged 3 commits from heluecht/friendica-addons:bluesky-worker into develop 2023-06-19 00:29:54 +02:00
Owner

All tasks that are executed by the "cron" hook are now done by spawned workers. This has got the improvement that there can be no blocking.

Also a lot more little improvements are now done. This ran for a couple of days without any problems. At this point nearly everything is implemented, with mostly only bugfixing left to do.

All tasks that are executed by the "cron" hook are now done by spawned workers. This has got the improvement that there can be no blocking. Also a lot more little improvements are now done. This ran for a couple of days without any problems. At this point nearly everything is implemented, with mostly only bugfixing left to do.
heluecht added 1 commit 2023-06-11 21:28:02 +02:00
MrPetovan requested changes 2023-06-12 02:14:54 +02:00
@ -11,1 +11,4 @@
*
* At some point in time:
* - Sending Quote shares https://atproto.com/lexicons/app-bsky-embed#appbskyembedrecord and https://atproto.com/lexicons/app-bsky-embed#appbskyembedrecordwithmedia
´*
Owner

Watch out for an extra Unicode character on this line.

Watch out for an extra Unicode character on this line.
Author
Owner

Done

Done
@ -118,3 +119,3 @@
}
$data = bluesky_get($pconfig['uid'], '/xrpc/app.bsky.actor.getProfile?actor=' . $did, HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $token]]]);
$data = bluesky_get($pconfig['uid'], '/xrpc/app.bsky.actor.getProfile?actor=' . urlencode($did), HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $token]]]);
Owner

I strongly suggest you switch to http_build_query() for these so that you don't have to remember about urlencode()

$data = bluesky_get($pconfig['uid'], '/xrpc/app.bsky.actor.getProfile?' . http_build_query(['actor' => $did], '', null, PHP_QUERY_RFC3986), HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $token]]]);

I strongly suggest you switch to `http_build_query()` for these so that you don't have to remember about `urlencode()` ```php $data = bluesky_get($pconfig['uid'], '/xrpc/app.bsky.actor.getProfile?' . http_build_query(['actor' => $did], '', null, PHP_QUERY_RFC3986), HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $token]]]); ```
Author
Owner

At some point in time I want to replace these calls with some new function that does all this stuff, including the token and whatever.

At some point in time I want to replace these calls with some new function that does all this stuff, including the token and whatever.
@ -427,2 +426,2 @@
bluesky_fetch_notifications($pconfig['uid']);
Logger::notice('importing notifications - done', ['user' => $pconfig['uid']]);
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_timeline.php', $pconfig['uid']);
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_notifications.php', $pconfig['uid']);
Owner
				Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], __DIR__ . '/bluesky_timeline.php', $pconfig['uid']);
				Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], __DIR__ . '/bluesky_notifications.php', $pconfig['uid']);
```php Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], __DIR__ . '/bluesky_timeline.php', $pconfig['uid']); Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], __DIR__ . '/bluesky_notifications.php', $pconfig['uid']); ````
Author
Owner

The __DIR__ doesn't work here. It has to be a relative path starting with the addon directory.

The `__DIR__` doesn't work here. It has to be a relative path starting with the addon directory.
@ -433,3 +431,2 @@
foreach ($feeds as $feed) {
Logger::debug('Importing feed', ['user' => $pconfig['uid'], 'feed' => $feed]);
bluesky_fetch_feed($pconfig['uid'], $feed);
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_feed.php', $pconfig['uid'], $feed);
Owner

Please use the relative path constants.

				Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], __DIR__ . '/bluesky_feed.php', $pconfig['uid'], $feed);
Please use the relative path constants. ```php Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], __DIR__ . '/bluesky_feed.php', $pconfig['uid'], $feed); ````
heluecht added 1 commit 2023-06-13 00:06:39 +02:00
heluecht added 1 commit 2023-06-13 22:43:58 +02:00
Author
Owner

I now created two new functions for these XPRC requests.

I now created two new functions for these XPRC requests.
MrPetovan approved these changes 2023-06-19 00:29:40 +02:00
MrPetovan merged commit aa0d829de6 into develop 2023-06-19 00:29:54 +02:00
heluecht deleted branch bluesky-worker 2023-06-22 22:02:37 +02:00
Sign in to join this conversation.
No description provided.