mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-12 17:44:31 +00:00
Update MentionPipeline, store non-local mentions
This commit is contained in:
parent
4be9d0f65f
commit
171492301b
2 changed files with 34 additions and 22 deletions
|
@ -10,6 +10,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use App\Services\StatusService;
|
||||||
|
|
||||||
class MentionPipeline implements ShouldQueue
|
class MentionPipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -59,17 +60,20 @@ class MentionPipeline implements ShouldQueue
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
Notification::firstOrCreate(
|
||||||
$notification = new Notification();
|
[
|
||||||
$notification->profile_id = $target;
|
'profile_id' => $target,
|
||||||
$notification->actor_id = $actor->id;
|
'actor_id' => $actor->id,
|
||||||
$notification->action = 'mention';
|
'action' => 'mention',
|
||||||
$notification->message = $mention->toText();
|
'item_type' => 'App\Status',
|
||||||
$notification->rendered = $mention->toHtml();
|
'item_id' => $status->id,
|
||||||
$notification->item_id = $status->id;
|
],
|
||||||
$notification->item_type = "App\Status";
|
[
|
||||||
$notification->save();
|
'message' => $mention->toText(),
|
||||||
} catch (Exception $e) {
|
'rendered' => $mention->toHtml()
|
||||||
}
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
StatusService::del($status->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,15 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use App\Services\AccountService;
|
||||||
use App\Services\CustomEmojiService;
|
use App\Services\CustomEmojiService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
use App\Jobs\MentionPipeline\MentionPipeline;
|
use App\Jobs\MentionPipeline\MentionPipeline;
|
||||||
use App\Mention;
|
use App\Mention;
|
||||||
use App\Services\AccountService;
|
|
||||||
use App\Hashtag;
|
use App\Hashtag;
|
||||||
use App\StatusHashtag;
|
use App\StatusHashtag;
|
||||||
use App\Services\TrendingHashtagService;
|
use App\Services\TrendingHashtagService;
|
||||||
|
use App\Util\ActivityPub\Helpers;
|
||||||
|
|
||||||
class StatusTagsPipeline implements ShouldQueue
|
class StatusTagsPipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -89,17 +90,24 @@ class StatusTagsPipeline implements ShouldQueue
|
||||||
return $tag &&
|
return $tag &&
|
||||||
$tag['type'] == 'Mention' &&
|
$tag['type'] == 'Mention' &&
|
||||||
isset($tag['href']) &&
|
isset($tag['href']) &&
|
||||||
substr($tag['href'], 0, 8) === 'https://' &&
|
substr($tag['href'], 0, 8) === 'https://';
|
||||||
parse_url($tag['href'], PHP_URL_HOST) == config('pixelfed.domain.app');
|
|
||||||
})
|
})
|
||||||
->map(function($tag) use($status) {
|
->map(function($tag) use($status) {
|
||||||
$parts = explode('/', $status['href']);
|
if(Helpers::validateLocalUrl($tag['href'])) {
|
||||||
if(!$parts) {
|
$parts = explode('/', $tag['href']);
|
||||||
return;
|
if(!$parts) {
|
||||||
}
|
return;
|
||||||
$pid = AccountService::usernameToId(end($parts));
|
}
|
||||||
if(!$pid) {
|
$pid = AccountService::usernameToId(end($parts));
|
||||||
return;
|
if(!$pid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$acct = Helpers::profileFetch($tag['href']);
|
||||||
|
if(!$acct) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$pid = $acct->id;
|
||||||
}
|
}
|
||||||
$mention = new Mention;
|
$mention = new Mention;
|
||||||
$mention->status_id = $status->id;
|
$mention->status_id = $status->id;
|
||||||
|
|
Loading…
Reference in a new issue