mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
Update LikePipeline
This commit is contained in:
parent
87376446fe
commit
f92b259232
3 changed files with 10 additions and 14 deletions
|
@ -69,19 +69,13 @@ class LikePipeline implements ShouldQueue
|
|||
$notification->profile_id = $status->profile_id;
|
||||
$notification->actor_id = $actor->id;
|
||||
$notification->action = 'like';
|
||||
$notification->message = $like->toText();
|
||||
$notification->rendered = $like->toHtml();
|
||||
$notification->message = $like->toText($status->in_reply_to_id ? 'comment' : 'post');
|
||||
$notification->rendered = $like->toHtml($status->in_reply_to_id ? 'comment' : 'post');
|
||||
$notification->item_id = $status->id;
|
||||
$notification->item_type = "App\Status";
|
||||
$notification->save();
|
||||
|
||||
Cache::forever('notification.'.$notification->id, $notification);
|
||||
|
||||
$redis = Redis::connection();
|
||||
$key = config('cache.prefix').':user.'.$status->profile_id.'.notifications';
|
||||
$redis->lpush($key, $notification->id);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
app/Like.php
11
app/Like.php
|
@ -27,19 +27,20 @@ class Like extends Model
|
|||
return $this->belongsTo(Status::class);
|
||||
}
|
||||
|
||||
public function toText()
|
||||
public function toText($type = 'post')
|
||||
{
|
||||
$actorName = $this->actor->username;
|
||||
$msg = $type == 'post' ? __('notification.likedPhoto') : __('notification.likedComment');
|
||||
|
||||
return "{$actorName} ".__('notification.likedPhoto');
|
||||
return "{$actorName} ".$msg;
|
||||
}
|
||||
|
||||
public function toHtml()
|
||||
public function toHtml($type = 'post')
|
||||
{
|
||||
$actorName = $this->actor->username;
|
||||
$actorUrl = $this->actor->url();
|
||||
$msg = $type == 'post' ? __('notification.likedPhoto') : __('notification.likedComment');
|
||||
|
||||
return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> ".
|
||||
__('notification.likedPhoto');
|
||||
return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> ".$msg;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
return [
|
||||
|
||||
'likedPhoto' => 'liked your photo.',
|
||||
'likedPhoto' => 'liked your post.',
|
||||
'likedComment' => 'liked your comment.',
|
||||
'startedFollowingYou' => 'started following you.',
|
||||
'commented' => 'commented on your post.',
|
||||
'mentionedYou' => 'mentioned you.',
|
||||
|
|
Loading…
Reference in a new issue