1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Websockets

This commit is contained in:
David Bomba 2024-07-30 09:28:15 +10:00
parent 1076f44fb3
commit 3bb60bdefd
9 changed files with 59 additions and 86 deletions

View File

@ -13,15 +13,21 @@ namespace App\Events\Client;
use App\Models\Client;
use App\Models\Company;
use League\Fractal\Manager;
use League\Fractal\Resource\Item;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use App\Transformers\ArraySerializer;
use Illuminate\Queue\SerializesModels;
use App\Transformers\ClientTransformer;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
/**
* Class ClientWasArchived.
*/
class ClientWasArchived
class ClientWasArchived implements ShouldBroadcast
{
use Dispatchable;
use InteractsWithSockets;
@ -50,13 +56,34 @@ class ClientWasArchived
$this->event_vars = $event_vars;
}
// /**
// * Get the channels the event should broadcast on.
// *
// * @return Channel|array
// */
public function broadcastWith()
{
$manager = new Manager();
$manager->setSerializer(new ArraySerializer());
$class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->client));
$transformer = new $class();
$resource = new Item($this->client, $transformer, $this->client->getEntityType());
$data = $manager->createData($resource)->toArray();
return $data;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return [];
return [
new PrivateChannel("company-{$this->company->company_key}"),
];
}
}

View File

@ -27,7 +27,6 @@ use Illuminate\Contracts\Translation\HasLocalePreference;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Cache;
use Laracasts\Presenter\PresentableTrait;
/**
@ -124,7 +123,7 @@ class Client extends BaseModel implements HasLocalePreference
use AppSetup;
use ClientGroupSettingsSaver;
use Excludable;
protected $presenter = ClientPresenter::class;
protected $hidden = [

View File

@ -32,10 +32,10 @@
"type": "project",
"require": {
"php": "^8.2",
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-curl": "*",
"afosto/yaac": "^1.4",
"asm/php-ansible": "dev-main",
"authorizenet/authorizenet": "^2.0",
@ -57,11 +57,10 @@
"hedii/laravel-gelf-logger": "^9",
"horstoeko/orderx": "dev-master",
"horstoeko/zugferd": "^1",
"horstoeko/zugferdvisualizer":"^1",
"horstoeko/zugferdvisualizer": "^1",
"hyvor/php-json-exporter": "^0.0.3",
"imdhemy/laravel-purchases": "^1.7",
"intervention/image": "^2.5",
"invoiceninja/inspector": "^3.0",
"invoiceninja/einvoice": "dev-main",
"invoiceninja/ubl_invoice": "^2",
"josemmo/facturae-php": "^1.7",

72
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": "edc6905124cb32fef6a13befb3d5a4e1",
"content-hash": "8fdb8245fbc563f8c09da161876f52a7",
"packages": [
{
"name": "adrienrn/php-mimetyper",
@ -2585,7 +2585,7 @@
},
{
"name": "google/apiclient-services",
"version": "v0.365.0",
"version": "v0.366.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git",
@ -2623,7 +2623,7 @@
],
"support": {
"issues": "https://github.com/googleapis/google-api-php-client-services/issues",
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.365.0"
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.366.0"
},
"time": "2024-07-11T01:08:44+00:00"
},
@ -4111,68 +4111,6 @@
},
"time": "2024-07-22T02:40:27+00:00"
},
{
"name": "invoiceninja/inspector",
"version": "v3.0",
"source": {
"type": "git",
"url": "https://github.com/invoiceninja/inspector.git",
"reference": "29bc1ee7ae9d967287ecbd3485a2fee41a13e65f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/invoiceninja/inspector/zipball/29bc1ee7ae9d967287ecbd3485a2fee41a13e65f",
"reference": "29bc1ee7ae9d967287ecbd3485a2fee41a13e65f",
"shasum": ""
},
"require": {
"doctrine/dbal": "^4.0",
"illuminate/support": "^11.0",
"php": "^8.2"
},
"require-dev": {
"orchestra/testbench": "^9.1",
"phpunit/phpunit": "^11.1"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"InvoiceNinja\\Inspector\\InspectorServiceProvider"
],
"aliases": {
"Inspector": "InvoiceNinja\\Inspector\\InspectorFacade"
}
}
},
"autoload": {
"psr-4": {
"InvoiceNinja\\Inspector\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Benjamin Beganović",
"email": "benjamin.beganovic4@outlook.com",
"role": "Developer"
}
],
"description": "Simplified database records management",
"homepage": "https://github.com/invoiceninja/inspector",
"keywords": [
"inspector",
"invoiceninja"
],
"support": {
"issues": "https://github.com/invoiceninja/inspector/issues",
"source": "https://github.com/invoiceninja/inspector/tree/v3.0"
},
"time": "2024-06-04T12:31:47+00:00"
},
{
"name": "invoiceninja/ubl_invoice",
"version": "v2.2.2",
@ -19598,10 +19536,10 @@
"prefer-lowest": false,
"platform": {
"php": "^8.2",
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-curl": "*"
"ext-libxml": "*"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"

View File

@ -193,7 +193,7 @@ return [
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\ComposerServiceProvider::class,

View File

@ -39,7 +39,7 @@ return [
'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com'),
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'encrypted' => false,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [

1
public/build/assets/app-039bd735.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,13 @@
|
*/
Broadcast::channel('App.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
// Broadcast::channel('App.User.{id}', function ($user, $id) {
// nlog($id);
// return false;
// // return (int) $user->id === (int) $id;
// });
Broadcast::channel('company-{company_key}', function (\App\Models\User $user, string $company_key) {
return $user->company()->company_key === $company_key;
});

View File

@ -49,3 +49,5 @@ Route::get('checkout/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', [C
Route::get('mollie/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', [Mollie3dsController::class, 'index'])->middleware('domain_db')->name('mollie.3ds_redirect');
Route::get('gocardless/ibp_redirect/{company_key}/{company_gateway_id}/{hash}', [GoCardlessController::class, 'ibpRedirect'])->middleware('domain_db')->name('gocardless.ibp_redirect');
Route::get('.well-known/apple-developer-merchantid-domain-association', [ApplePayDomainController::class, 'showAppleMerchantId']);
Broadcast::routes(['middleware' => ['token_auth']]);