-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(service): make whatsapp no-op (#438)
Showing
8 changed files
with
44 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,14 @@ | ||
|
||
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/nikoksr/notify/service/whatsapp) | ||
## IMPORTANT | ||
|
||
## Prerequisites | ||
### Broken state; see [#274](https://github.com/nikoksr/notify/issues/274) | ||
|
||
You will need a registered WhatsApp phone number to be used as source for sending WhatsApp messages. | ||
Since our previous WhatsApp client library was abandoned, we had to switch to a new one. Unfortunately, the new library | ||
is not yet ready for production use. We are working on a solution, but it will take some time. | ||
|
||
## Usage | ||
The broken client library caused our CI pipeline to break and for that reason we decided to turn the WhatsApp service | ||
into a no-op service. This means that the WhatsApp service will not send any notifications, but it will not return any | ||
errors either. This is a temporary solution until we have a working client library. We chose no-op over a hard error to | ||
prevent breaking existing applications. | ||
|
||
In the current implementation, authentication is implemented using 2 ways: | ||
|
||
1. Scanning QR code from terminal using a registered WhatsApp device. | ||
|
||
- Go to WhatsApp on your device. | ||
- Click on the ellipsis icon (3 vertical dots) on top right, then click on "WhatsApp Web". | ||
- Click on the "+" icon and scan the QR code from terminal. | ||
|
||
> Refer: [Login (go-whatsapp)](https://github.com/Rhymen/go-whatsapp#login) and [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) for more details. | ||
2. Providing the Session credentials explicitly. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/nikoksr/notify" | ||
"github.com/nikoksr/notify/service/whatsapp" | ||
) | ||
|
||
func main() { | ||
whatsappSvc, err := whatsapp.New() | ||
if err != nil { | ||
log.Fatalf("whatsapp.New() failed: %s", err.Error()) | ||
} | ||
|
||
err = whatsappSvc.LoginWithQRCode() | ||
if err != nil { | ||
log.Fatalf("whatsappSvc.LoginWithQRCode() failed: %s", err.Error()) | ||
} | ||
|
||
whatsappSvc.AddReceivers("Contact1") | ||
|
||
notifier := notify.New() | ||
notifier.UseServices(whatsappSvc) | ||
|
||
err = notifier.Send(context.Background(), "subject", "message") | ||
if err != nil { | ||
log.Fatalf("notifier.Send() failed: %s", err.Error()) | ||
} | ||
|
||
log.Println("notification sent") | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,8 @@ | ||
/* | ||
Package whatsapp provides message notification integration for WhatsApp. | ||
Package whatsapp is currently a [ NO-OP ] service! We're sorry for the inconveniences. We're already working on a fix. | ||
Usage: | ||
Please read this [1] for more. Thanks! | ||
package main | ||
import ( | ||
"log" | ||
"github.com/nikoksr/notify" | ||
"github.com/nikoksr/notify/service/whatsapp" | ||
) | ||
func main() { | ||
whatsappSvc, err := whatsapp.New() | ||
if err != nil { | ||
log.Fatalf("whatsapp.New() failed: %s", err.Error()) | ||
} | ||
err = whatsappSvc.LoginWithQRCode() | ||
if err != nil { | ||
log.Fatalf("whatsappSvc.LoginWithQRCode() failed: %s", err.Error()) | ||
} | ||
whatsappSvc.AddReceivers("Contact1") | ||
notifier := notify.New() | ||
notifier.UseServices(whatsappSvc) | ||
err = notifier.Send(context.Background(), "subject", "message") | ||
if err != nil { | ||
log.Fatalf("notifier.Send() failed: %s", err.Error()) | ||
} | ||
log.Println("notification sent") | ||
} | ||
[1]:https://github.com/nikoksr/notify/issues/274 | ||
*/ | ||
package whatsapp |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.