Giter VIP home page Giter VIP logo

laravel-notification-subscriptions's People

Contributors

blakekrone avatar clintwinter avatar earnjam avatar fabiofdsantos avatar jtolj avatar laravel-shift avatar liran-co avatar sankarsuda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-notification-subscriptions's Issues

Listener not called

When I send a notification, the EventServiceProvider boot method is called, however, the listener is not called.
When I place a log::debug in the boot method, it shows up, but in the listener it does not show up
And ofcourse the unsubscribes are not handled and the mail is sent out

Any idea why (running L8)

PHP 8 compatibility?

I haven't source dived to check on this, but is this package compatible with PHP 8? It's locked into the 7.x branch because of the composer settings, so it's throwing a warning when I try to update to PHP 8.

I was wondering if it's just a case of needing to add that to composer.json or if there are things that need to be changed in the code.

Unable to unsubscribe from a notification that implements the getSubscriptionModel() function

Hello,

Thanks for the package - this is the exact functionality I was looking to implement.

I have created a base notification class that I plan to use for all notifications on a given Class. The base notification implements an interface which declares getSubscriptionModel().

The goal is to be able to unsubscribe from notifications for any particular Model of that class; however, if it's setup like this, it breaks attempts to unsubscribe from the Notification class itself.

ex:

interface CanUnsubscribe
{
    public function getSubscriptionModel($notifiable) : \Illuminate\Database\Eloquent\Model;
}
abstract class RequestNotification extends Notification implements ShouldQueue, CanUnsubscribe
{
    use Queueable;

    public Request $request;

    public bool $ignoreSubscriptions;

    public function __construct(Request $request, $ignore = false)
    {
        $this->request = $request;
        $this->ignoreSubscriptions = $ignore;
    }

    public function getSubscriptionModel($notifiable): \Illuminate\Database\Eloquent\Model
    {
        return $this->request;
    }
}
class NotifyRequestStateChanged extends RequestNotification
{
  //  ... concrete notification ....
}

Then if you try

$user->unsubscribe(NotifyRequestStateChanged)

The user will still receive the notification unless you specify the model in the unsubscribe call.

I would expect that if you've unsubscribed from a notification, you should not receive that notification, regardless of it's implementation of the getSubscriptionModel() function or not.

Laravel 11 Support

Laravel 11 support would be great. I think it sould just be an addition to composer.json

Unable to unsubscribe

I followed the instructions in the readme to unsubscribe a user from a specific channel, I am trying to unsubscribe a user from mail but the mail is sent anyway. I even tried switching to OptInSubscriotion() which should prevent all mails from sending by default but the mails still get sent. I followed the steps strictly and have gone over it several times. Not sure what is wrong.

EDIT:

Turns out I wasn't importing the necessary classes properly... silly😅.

N+1

When calling isSubscribed on a user->with('NotificationSubscriptions)

The following returns an n+1 problem, as you are requerying instead of using the loaded relations

return $this->notificationSubscriptions()->where('type', $type)->where('channel', $channel)->model($model)->first();

Laravel 8.x compatibility

This package seems to be locked to Laravel 6.x and 7.x via composer. Is it compatible with 8.x and can composer be updated to reflect this?

The package doesn't let you use the NotificationSending listener in the app

In my App/Providers/EventServiceProvider.php, I was listening to the NotificationSending event to do some checks before sending a notification as follows:

// namespace App\Providers;

protected $listen = [
    'Illuminate\Notifications\Events\NotificationSending' => [
        'App\Listeners\NotificationSendingListener',
    ],
];

After I installed this package, my App\Listeners\NotificationSendingListener does not seem to work.
I believe, it is being overridden by the package because the package is listening to the same event as:

// namespace LiranCo\NotificationSubscriptions\Providers;

protected $listen = [
    'Illuminate\Notifications\Events\NotificationSending' => [
        'LiranCo\NotificationSubscriptions\Listeners\NotificationSendingListener',
    ],
];

Maybe the same array key issue and the first value gets overridden by the second.

As the protected $listen is an associative array and using the same array key results in the last key-value pair actually being registered and ignoring any previous ones.

Found the reason causing this issue.

As we know the listener LiranCo\NotificationSubscriptions\Listeners\NotificationSendingListener checks if the user has unsubscribed from the notification and returns false which suppress that notification from being processed and sent out to the user. All good here.

But if user has not unsubscribed from the notification, this class returns $event.
And this causes the other listeners for the same event NotificationSending not processed.

Solution

Returning void return; instead of return $event in the handle method of LiranCo\NotificationSubscriptions\Listeners\NotificationSendingListener class resolves the issue.

@liran-co I'll open a pull request soon for a review.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.