1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-21 23:32:39 +00:00

Add Push Notifications

This commit is contained in:
Daniel Supernault 2024-07-22 01:13:59 -06:00
parent c042d13590
commit 83ce8fd78e
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
5 changed files with 114 additions and 2 deletions

View file

@ -8,10 +8,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Util\RateLimit\User as UserRateLimit;
use App\Services\AvatarService;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use NotificationChannels\WebPush\HasPushSubscriptions;
use NotificationChannels\Expo\ExpoPushToken;
class User extends Authenticatable
{
use Notifiable, SoftDeletes, HasApiTokens, UserRateLimit;
use Notifiable, SoftDeletes, HasApiTokens, UserRateLimit, HasFactory, HasPushSubscriptions;
/**
* The attributes that should be mutated to dates.
@ -23,6 +26,7 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
'2fa_setup_at' => 'datetime',
'last_active_at' => 'datetime',
'expo_token' => ExpoPushToken::class
];
/**
@ -115,4 +119,8 @@ class User extends Authenticatable
return AvatarService::get($this->profile_id);
}
public function routeNotificationForExpo(): ?ExpoPushToken
{
return $this->expo_token;
}
}

View file

@ -19,6 +19,7 @@
"doctrine/dbal": "^3.0",
"intervention/image": "^2.4",
"jenssegers/agent": "^2.6",
"laravel-notification-channels/expo": "^2.0",
"laravel-notification-channels/webpush": "^8.0",
"laravel/framework": "^11.0",
"laravel/helpers": "^1.1",

66
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "55dc6d48024fd1d158f8777eda3ea624",
"content-hash": "53a815fd998a7264135d59184253d0de",
"packages": [
{
"name": "aws/aws-crt-php",
@ -2247,6 +2247,70 @@
],
"time": "2020-06-13T08:05:20+00:00"
},
{
"name": "laravel-notification-channels/expo",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/laravel-notification-channels/expo.git",
"reference": "29d038b6409077ac4c671cc5587a4dc7986260b0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel-notification-channels/expo/zipball/29d038b6409077ac4c671cc5587a4dc7986260b0",
"reference": "29d038b6409077ac4c671cc5587a4dc7986260b0",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/guzzle": "^7.1",
"illuminate/contracts": "^11.0",
"illuminate/notifications": "^11.0",
"illuminate/support": "^11.0",
"php": "~8.3"
},
"require-dev": {
"larastan/larastan": "^2.0",
"laravel/pint": "^1.0",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^11.0"
},
"suggest": {
"ext-zlib": "Required for compressing payloads exceeding 1 KiB in size."
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"NotificationChannels\\Expo\\ExpoServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"NotificationChannels\\Expo\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Muhammed Sari",
"email": "muhammed@dive.be",
"homepage": "https://dive.be",
"role": "Developer"
}
],
"description": "Expo Notifications Channel for Laravel",
"homepage": "https://github.com/laravel-notification-channels/expo",
"support": {
"issues": "https://github.com/laravel-notification-channels/expo/issues",
"source": "https://github.com/laravel-notification-channels/expo/tree/v2.0.0"
},
"time": "2024-03-18T07:49:28+00:00"
},
{
"name": "laravel-notification-channels/webpush",
"version": "8.0.0",

View file

@ -35,4 +35,7 @@ return [
'secret' => env('STRIPE_SECRET'),
],
'expo' => [
'access_token' => env('EXPO_ACCESS_TOKEN'),
],
];

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('expo_token')->nullable();
$table->boolean('notify_like')->default(true);
$table->boolean('notify_follow')->default(true);
$table->boolean('notify_mention')->default(true);
$table->boolean('notify_comment')->default(true);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('expo_token');
$table->dropColumn('notify_like');
$table->dropColumn('notify_follow');
$table->dropColumn('notify_mention');
$table->dropColumn('notify_comment');
});
}
};