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

feat: add share and open actions #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cyrinux
Copy link

@cyrinux cyrinux commented Jun 16, 2022

Hello,

Thanks for this cool project.

I add the possibility to share a value from the notification with using this extra:
"client::notification" -> "actions" -> "share"
And open an URL with:
"client::notification" -> "actions" -> "open"

According to the android documentation, the numbers maximum of actions can be 3.

Documentation here: gotify/website#58

Exemple of share usage here: tuffnerdstuff/hauk-snitch#16

cyrinux added a commit to cyrinux/gotify-website that referenced this pull request Jun 16, 2022
cyrinux added a commit to cyrinux/hauk-snitch that referenced this pull request Jun 16, 2022
This will be nice to be able to share the url with chat apps for example without open the link ourself.

I did the gotify android PR to make this working.

This can be merge before the gotify android but will not work while not merged gotify/android#236.
@cyrinux cyrinux changed the title feat: add share and open action feat: add share and open actions Jun 16, 2022
@@ -323,6 +323,30 @@ private void showNotification(
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
.setContentIntent(contentIntent);

String actionOpen =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your use-cases for both features, and why do we need another url open, when there is already https://gotify.net/docs/msgextras#clientnotification click.url

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to be able to open another url for example from the actions buttons under the notification

The current implementation seems too unflexible. You could already have functionality in mark down for opening a URL. Maybe we could parse the links inside a markdown message and automatically create buttons for these. Otherwise, a more generic approach would look like:

{
  "extras": {
    "client::action": {
      "buttons": [
        {
          "label": "Acknowledge",
          "http": {
            "method": "post",
            "url": "https://example.com/ack?id=5",
            "headers": {
              "Authorization": "bearer abcde"
            }
          }
        },
        // another button
      ]
    }
  }
}

But something like this would require more input from other users, so that we know this is fulfills their use cases. Perhaps there is already a standard for defining actions like this, f.ex Microsoft Teams supports such buttons.

Could you give me a concrete use-case for the share feature.

@cyrinux
Copy link
Author

cyrinux commented Jun 18, 2022

This is to be able to open another url for example from the actions buttons under the notification, and share a text or url from the another button under the notification.
With 'open' I can for example open a url to ack an alert, and in the click.url I will point to this alert for example.
I use pushover in the past, and this reproduce the same behavior.

@cyrinux
Copy link
Author

cyrinux commented Jun 18, 2022

I like a lot the generic approach for the actions and honestly I thought about it but I'm not Java dev at all and I made the simple way.
Still about those buttons, but I understand the max is three buttons. So if share enable, two generic actions buttons and the share button. Or three generic actions buttons if share not used.

Share buttons should be this special intent I use and, we should be able to put the content we want in it ideally, or the full notification content if you think its overkill. You can see an example in the hauk-snitch pr tuffnerdstuff/hauk-snitch#16 . This make able to quick share some text/link without opening this link.

Does it make sens for you?
Could you implement your cool proposition?

About the parsing of the markdown, why not but with the limitation of actions button, maybe it's too hard to make a smart algo to choose which links? Or we put as actions the 2 or 3 first or last links only?

@jmattheis
Copy link
Member

The share/copy functionality could be included in the button definition. The notification then would include the first 3 buttons and all buttons would be displayed, if you'd go into the app and view the message.

{
  "extras": {
    "client::action": {
      "buttons": [
        {
          "label": "Copy",
          "clipboard": {
            "text": "add this to clipboard"
          }
        },
        // another button
      ]
    }
  }
}

I won't implement this, because I don't need it. This feature also requires discussion on how to define the buttons and what should be supported.

I think the first 3 links would suffice, and the markdown library that is used in the android app should support getting all links.

@cyrinux
Copy link
Author

cyrinux commented Jun 18, 2022

Ok, so "clipboard" in this case will trigger a copy of the text in clipboard, and we can add the same for "share" that open this special share intent from where you can copy, and share to messaging app for example, ok for you ?

@cyrinux
Copy link
Author

cyrinux commented Jun 18, 2022

Here a screenshot of what I obtain with the actual content of the PR, to clarify what i want to achieve.
Being able to interact from the notification so I dont have to open the Gotify app:

image

If I manage to get those actions managed with the format you purpose, would you approve of having such feature ?

@jmattheis
Copy link
Member

and we can add the same for "share" that open this special share intent from where you can copy, and share to messaging app for example, ok for you ?

If that is a feature that multiple users want, then yes.

f I manage to get those actions managed with the format you purpose, would you approve of having such feature ?

Like I said, it would first require input from other users, I don't want features that are only used by one person

@maximbaz
Copy link

Hi @jmattheis! I am one other user who is very interested in this feature, I think it's quite neat and flexible way to build various integrations using gotify!

Hauk-snitch, as shown on the screenshot above, is one case which I'm also actually very interested. To explain what happens in that case, I want to temporarily share my location to a friend, I press a button, magic happens on backend and a unique link is generated and sent to me using Gotify. To make the workflow perfectly efficient, I don't want to open Gotify app, I don't want to open the link in my browser, I just want to hit Share and directly send it to my friend.

In another example, which I also really want to achieve, is to make neat integration with monitoring / oncall practices. I already use Gotify for this, but I currently need to open Gotify app to reach all possible actions (acknowledge incident, open dashboard for details, silence, escalate, edit alert, etc). There are probably two or three actions that I actually need in 99% of cases, so if I could make some extra buttons directly in the notification (like is shown by this pr), it would again increase my efficiency and pleasure of using Gotify 😉

Hope that gives some context, for sure +1 from me!

@jmattheis
Copy link
Member

Yes, but I'm looking for users that will use the same API with different use-cases. I don't want to build the API for one specific use-case.

@maximbaz
Copy link

I would not have put location-sharing-with-friends and incidents-management in the same single use-case category to be honest...

@jmattheis
Copy link
Member

I'm not arguing against the feature itself, I'm trying to find an API that fits most use-cases. This means the actual definition inside the "extras" block inside the message.

Only saying that it could be used for these use-cases doesn't really help me figure out, if that's the right API for defining actions. The best way for this would be to create an issue in gotify/server with the feature definition and some examples for possible actions, and then ask inside the gotify chat room, if someone has input for this.

@cyrinux
Copy link
Author

cyrinux commented Jun 22, 2022

Thanks guys, please find the feature request here gotify/server#494 . I put in some more idea, like being able to start a call or text from an button action.
What is the "gotify chat room" please ? Can you share it for me ?

@jmattheis
Copy link
Member

@cyrinux the chat is here https://matrix.to/#/#gotify:matrix.org

@BenjaminCz0101
Copy link

Hello,
I receive a notification in Gotify when the alarm system goes off. In order to acknowledge this I need a button. I tried the following but nothing works. What am I doing wrong ?

` const axios = require("axios");

const url = "https://192.168.178.XXX/message?token=AFHtgBfY0ruIUEz";
const bodyFormData = {
title: "Test",
message: "Alarm Ausgelöst",
priority: 8,
extras: {
"client::action": {
"buttons": [
{
"label": "Acknowledge",
"http": {
"method": "post",
"url": "https://example.com/ack?id=5",
"headers": {
"Authorization": "bearer abcde"
}
}
},
// another button
]
}
}
};

axios({
method: "post",
headers: {
"Content-Type": "application/json",
},
url: url,
data: bodyFormData,
})
.then((response) => console.log(response.data))
.catch((err) => console.log(err.response ? error.response.data : err)); `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants