android icon indicating copy to clipboard operation
android copied to clipboard

feat: add share and open actions

Open cyrinux opened this issue 2 years ago • 13 comments

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: https://github.com/gotify/website/pull/58

Exemple of share usage here: https://github.com/tuffnerdstuff/hauk-snitch/pull/16

cyrinux avatar Jun 16 '22 15:06 cyrinux

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 avatar Jun 18 '22 12:06 cyrinux

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 https://github.com/tuffnerdstuff/hauk-snitch/pull/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?

cyrinux avatar Jun 18 '22 14:06 cyrinux

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.

jmattheis avatar Jun 18 '22 15:06 jmattheis

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 avatar Jun 18 '22 15:06 cyrinux

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 ?

cyrinux avatar Jun 18 '22 18:06 cyrinux

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

jmattheis avatar Jun 19 '22 09:06 jmattheis

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!

maximbaz avatar Jun 20 '22 13:06 maximbaz

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.

jmattheis avatar Jun 22 '22 18:06 jmattheis

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

maximbaz avatar Jun 22 '22 18:06 maximbaz

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.

jmattheis avatar Jun 22 '22 18:06 jmattheis

Thanks guys, please find the feature request here https://github.com/gotify/server/issues/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 ?

cyrinux avatar Jun 22 '22 19:06 cyrinux

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

jmattheis avatar Jun 26 '22 09:06 jmattheis

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)); `

BenjaminCz0101 avatar May 05 '24 21:05 BenjaminCz0101