Skip to content

Commit

Permalink
Fixed missing queable notification feature
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Oct 29, 2024
1 parent 20f6f96 commit 8a2d019
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/masonite/notification/Notifiable.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class Notifiable:
Usage:
user.notify(WelcomeNotification())
"""

def notify(self, notification, drivers=[], dry=False, fail_silently=False):
"""Send the given notification."""
from wsgi import application


if hasattr(notification, "send"):
notification.send(notification, drivers, dry, fail_silently)

return application.make("notification").send(
self, notification, drivers, dry, fail_silently
)
Expand Down
9 changes: 9 additions & 0 deletions src/masonite/queues/Queueable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class Queueable:

run_again_on_fail = True
run_times = 3

def queue(self):
return "default"


def handle(self):
pass
Expand All @@ -15,3 +19,8 @@ def failed(self, obj, e):

def __repr__(self):
return self.__class__.__name__

def send(self, notification, driver="", dry=False, fail_silently=False):
from ..facades.Queue import Queue
Queue.push(notification, queue=self.queue())
print('Sending to queue', notification)
5 changes: 3 additions & 2 deletions tests/integrations/notifications/OneTimePassword.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from src.masonite.notification import Notification, Textable
from src.masonite.mail import Mailable
from src.masonite.mail import Mailable
from src.masonite.queues.Queueable import Queueable


class OneTimePassword(Notification, Mailable, Textable):
class OneTimePassword(Notification, Mailable, Textable, Queueable):
def to_mail(self, notifiable):
return (
self.to(notifiable.email)
Expand All @@ -16,4 +17,4 @@ def to_vonage(self, notifiable):
return self.text_message("Welcome !").to("6314870798").from_("33123456789")

def via(self, notifiable):
return ["vonage"]
return ["mail"]

0 comments on commit 8a2d019

Please sign in to comment.