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

AdaptiveCardActions OpenUrl class is missing var "url" in __init__ method #159

Closed
cpissay opened this issue Apr 26, 2021 · 2 comments
Closed

Comments

@cpissay
Copy link

cpissay commented Apr 26, 2021

Version: 1.6

The Problem

In the __init__ method for class OpenUrl in Adaptive Card Actions the variable url is not being set. This results in the card being "malformed" as the Action UrlSubmit element will be missing the url attribute.

I am not entirely sure if I am doing something wrong while instantiating OpenUrl.
I am just calling it like this,

from webexteamssdk.cards.actions import OpenUrl
actions = [
    OpenUrl("https://myurl",title="Click Me")
]

And this does not work.

Workaround:

  • Just use Markdown syntax in a TextBlock element.
    TextBlock("[Click Me](https://myurl)")
    OR
  • Create the json body using the Card Designer if this absolutely needs to be in the ActionSet
    And if there is any dynamic content, use string replace

Potential Fix??

I was able to sort of "fix" it by

  1. Adding self.url = url in the __init__ method.
  2. Appending "url" to the list being assigned to simple_properties in the super().__init__ call.

Here's an excerpt from file actions.py

class OpenUrl(AdaptiveCardComponent):
    """Open URL Action."""
    type = "Action.OpenUrl"

    def __init__(self, url, title=None, iconURL=None):
        self.title = title
        self.iconURL = iconURL

        super().__init__(
            serializable_properties=[],
            simple_properties=['type', 'title', 'iconURL'],
        )

Here's what I did to make it work

class OpenUrl(AdaptiveCardComponent):
    """Open URL Action."""
    type = "Action.OpenUrl"

    def __init__(self, url, title=None, iconURL=None):
        self.title = title
        self.iconURL = iconURL
        # Set variable url
        self.url = url

        super().__init__(
            serializable_properties=[],
            # Append string "url" to the list
            simple_properties=['url','type', 'title', 'iconURL'],
        )
@ntsphwoelfel
Copy link

Just noticed the same problem as you did!
Kinda breaking the purpose of a OpenUrl action without an url...

@cmlccie
Copy link
Collaborator

cmlccie commented Feb 19, 2024

Closing this issue. It looks like it was resolved in #175.

@cmlccie cmlccie closed this as completed Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants