1
0
Fork 0

Merge pull request #3234 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-02-12 22:44:07 -07:00 committed by GitHub
commit 1a935eacd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 5 deletions

View File

@ -43,6 +43,7 @@
- Updated Profile.vue component, fix v-once bug. ([4d003d00](https://github.com/pixelfed/pixelfed/commit/4d003d00)) - Updated Profile.vue component, fix v-once bug. ([4d003d00](https://github.com/pixelfed/pixelfed/commit/4d003d00))
- Updated filesystems config, set S3 visibility to public by default. Fixes #2913. ([49a53c27](https://github.com/pixelfed/pixelfed/commit/49a53c27)) - Updated filesystems config, set S3 visibility to public by default. Fixes #2913. ([49a53c27](https://github.com/pixelfed/pixelfed/commit/49a53c27))
- Updated CommentPipeline, improve parent reply_count calculation. ([ccc94802](https://github.com/pixelfed/pixelfed/commit/ccc94802)) - Updated CommentPipeline, improve parent reply_count calculation. ([ccc94802](https://github.com/pixelfed/pixelfed/commit/ccc94802))
- Updated StatusTagsPipeline, process federated hashtags and mentions ([a84b1736](https://github.com/pixelfed/pixelfed/commit/a84b1736))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)

View File

@ -10,6 +10,11 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use App\Services\CustomEmojiService; use App\Services\CustomEmojiService;
use App\Services\StatusService; use App\Services\StatusService;
use App\Jobs\MentionPipeline\MentionPipeline;
use App\Mention;
use App\Services\AccountService;
use App\Hashtag;
use App\StatusHashtag;
class StatusTagsPipeline implements ShouldQueue class StatusTagsPipeline implements ShouldQueue
{ {
@ -37,15 +42,61 @@ class StatusTagsPipeline implements ShouldQueue
public function handle() public function handle()
{ {
$res = $this->activity; $res = $this->activity;
$status = $this->status;
$tags = collect($res['tag']);
collect($res['tag']) // Emoji
->filter(function($tag) { $tags->filter(function($tag) {
// todo: finish hashtag + mention import return $tag && $tag['type'] == 'Emoji' && isset($tag['id'], $tag['icon'], $tag['name']);
// return in_array($tag['type'], ['Emoji', 'Hashtag', 'Mention']);
return $tag && $tag['type'] == 'Emoji';
}) })
->map(function($tag) { ->map(function($tag) {
CustomEmojiService::import($tag['id'], $this->status->id); CustomEmojiService::import($tag['id'], $this->status->id);
}); });
// Hashtags
$tags->filter(function($tag) {
return $tag && $tag['type'] == 'Hashtag' && isset($tag['href'], $tag['name']);
})
->map(function($tag) use($status) {
$name = substr($tag['name'], 0, 1) == '#' ?
substr($tag['name'], 1) : $tag['name'];
$hashtag = Hashtag::firstOrCreate([
'slug' => str_slug($name)
], [
'name' => $name
]);
StatusHashtag::firstOrCreate([
'status_id' => $status->id,
'hashtag_id' => $hashtag->id,
'profile_id' => $status->profile_id,
'status_visibility' => $status->scope
]);
});
// Mentions
$tags->filter(function($tag) {
return $tag &&
$tag['type'] == 'Mention' &&
isset($tag['href']) &&
substr($tag['href'], 0, 8) === 'https://' &&
parse_url($tag['href'], PHP_URL_HOST) == config('pixelfed.domain.app');
})
->map(function($tag) use($status) {
$parts = explode('/', $status['href']);
if(!$parts) {
return;
}
$pid = AccountService::usernameToId(end($parts));
if(!$pid) {
return;
}
$mention = new Mention;
$mention->status_id = $status->id;
$mention->profile_id = $pid;
$mention->save();
MentionPipeline::dispatch($status, $mention);
});
} }
} }