-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💬 Improve Appwrite Messaging with Azure Notification Hubs Adapter #6382
Comments
hey can I work on this issue :) |
Hi @7h3-3mp7y-m4n have assigned the issue to you! Thank you for showing interest in contributing to Appwrite! Happy Hacktoberfest 🎃 Notes:
|
Thanks @Haimantika , don't worry I'm working on it , I'll be in touch if I have any issues while solving it . |
Hi @Haimantika can I work on this issue? |
Hi, it has been 4 days, I will have to reassign this issue to the next person. Is there an update? |
Kindly assign to me if no one's working on it |
Hey, I'm really sorry for reaching you late. Yeah, yeah I've been working on the issue, and right now I'm figuring out how to fix the process function. I'll reach out to you ASAP on Discord. |
Hi, anything else you need help in? |
Nah I just put it on discord |
Hi @7h3-3mp7y-m4n following up, is there an update? Will have to reassign the issue to the next person if you are not working on it. |
@Haimantika so far I came up with this , but I think I'm following a wrong path , it would be suitable if you assign someone else or assist me . <?php
namespace Utopia\Messaging\Adapters\Push;
use Utopia\Messaging\Messages\Push;
use Utopia\Messaging\Adapters\Push as PushAdapter;
class AzureNotificationHubs extends EmailAdapter
{ private string $connectionString;
public function __construct(string $connectionString)
{
$this->connectionString = $connectionString;
}
public function getName(): string
{
return 'Azure Notification Hubs';
}
public function getMaxMessagesPerRequest(): int
{
return 1000; // I need to adjust this cause azure notification have different plans I guess
}
protected function process(Push $message): string
{
/
$notificationPayload = [
'data' => [
'message' => $message->getMessage(),
],
];
$notificationPayload = json_encode($notificationPayload);
return $this->sendNotification($notificationPayload);
}
private function sendNotification(string $payload): string
{
$hubName = 'your-actual-hub-name'; // Swaping it with desire user hub name
$url = "https://$hubName.servicebus.windows.net/$hubName/messages";
$headers = [
'Authorization: ' . $this->connectionString,
'Content-Type: application/json',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
return curl_error($ch);
}
curl_close($ch);
return $response;
}
} |
Closing this issue as hacktoberfest is now over. Thank you to everyone who participated this year :) |
💭 Introduction
Having an app is cool, but having integrations is even cooler! 😎 It always brings a smile to my face when a website has the option to sign in with my GitHub account, so I don't have to go over the lengthy process of creating an account… The same can be said about messages! Every app with the option to enable push notifications, email, or SMS notifications gives the users confidence they won't miss anything important. We all have our channels we check the most, and having the ability to connect some app directly in there is always a positive.
Appwrite will use Utopia PHP messaging library to allow developers to get in touch with users using one of its many messaging adapters, such as Email, Discord, or Slack.
Since the messaging library supports adapters, there is always space for more. 😎 Each provider implements a method to send the message to the correct channel (usually using an HTTP request or a library) alongside a few configuration variables and methods to set what the adapter allows.
Your task is to implement support for Azure Notification Hubs in the Utopia PHP messaging library. This goes under Push category, so feel free to look at existing ones in the adapters folder. We have prepared detailed documentation on how to add a new messaging adapter. Please read the document and ensure you understand them before working on this issue.
🎯 Requirements
✅ Task Summary
If you have questions, need any help, or just want to hang out, make sure to join us on our Discord server.
Happy Appwriting!
The text was updated successfully, but these errors were encountered: