Skip to content
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

Closed
5 tasks
christyjacob4 opened this issue Oct 1, 2023 · 12 comments
Closed
5 tasks
Assignees
Labels
hacktoberfest Issues that can win you some cool swags!

Comments

@christyjacob4
Copy link
Member

💭 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

  • Experience with PHP.
  • Experience with Azure Notification Hubs.
  • Experience with Docker and Docker Compose.

✅ Task Summary

  • Ask to be assigned to the issue.
  • Wait to be assigned.
  • Implement Utopia PHP logger adapter for Push/Azure Notification Hubs.
  • Submit a pull request in utopia-php/messaging.
  • Write a blog post on the platform of your choosing on how to integrate and use the adapter you just created.

If you have questions, need any help, or just want to hang out, make sure to join us on our Discord server.

Happy Appwriting!

@christyjacob4 christyjacob4 added the hacktoberfest Issues that can win you some cool swags! label Oct 1, 2023
@7h3-3mp7y-m4n
Copy link

hey can I work on this issue :)

@Haimantika
Copy link
Contributor

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:

  1. Please update us with your progress every 3 days, so that we know that you are working on it.
  2. Join us on Discord - https://appwrite.io/discord to chat about Hacktoberfest and Appwrite!

@7h3-3mp7y-m4n
Copy link

Thanks @Haimantika , don't worry I'm working on it , I'll be in touch if I have any issues while solving it .

@Harsh3363
Copy link

Hi @Haimantika can I work on this issue?

@Haimantika
Copy link
Contributor

Haimantika commented Oct 6, 2023

Thanks @Haimantika , don't worry I'm working on it , I'll be in touch if I have any issues while solving it .

Hi, it has been 4 days, I will have to reassign this issue to the next person. Is there an update?

@aoamusat
Copy link

aoamusat commented Oct 6, 2023

Kindly assign to me if no one's working on it

@7h3-3mp7y-m4n
Copy link

Thanks @Haimantika , don't worry I'm working on it , I'll be in touch if I have any issues while solving it .

Hi, it has been 4 days, I will have to reassign this issue to the next person. Is there an update?

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.

@Haimantika
Copy link
Contributor

Thanks @Haimantika , don't worry I'm working on it , I'll be in touch if I have any issues while solving it .

Hi, it has been 4 days, I will have to reassign this issue to the next person. Is there an update?

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?

@7h3-3mp7y-m4n
Copy link

Thanks @Haimantika , don't worry I'm working on it , I'll be in touch if I have any issues while solving it .

Hi, it has been 4 days, I will have to reassign this issue to the next person. Is there an update?

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

@Haimantika
Copy link
Contributor

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.

@7h3-3mp7y-m4n
Copy link

7h3-3mp7y-m4n commented Oct 19, 2023

@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;
    }
}

@tessamero
Copy link

Closing this issue as hacktoberfest is now over. Thank you to everyone who participated this year :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues that can win you some cool swags!
Projects
None yet
Development

No branches or pull requests

6 participants