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

Alert info is missing :data, preventing links to messages working #7

Open
Alex-Munro opened this issue Jun 19, 2022 · 1 comment
Open

Comments

@Alex-Munro
Copy link

Hi Andrea 👋

In the example at https://ag91.github.io/blog/2022/04/01/ol-emacs-slack-added-support-for-thread-links/

These lines seem to define the destination for the link

(if (plist-get info :data)
            (format "%s|%s|ts:%s"
                    (plist-get (plist-get info :data) :team-id)
                    (plist-get (plist-get info :data) :room-id)
                    (plist-get (plist-get info :data) :ts))
          (plist-get info :title))

With the example as-is, the org links seem to only have the results of (plist-get info :title).

Swapping if (plist-get info :data) with (if (plist-member info :data) causes the (format "%s|%s|ts:%s" ... to output, but none of those keys seem available? An example link added to Slack.org via the Alert notifier is [[emacs-slack:nil|nil|ts:nil][Feeling great!]].

Using org-store-link on the same slack message returns [[emacs-slack:T7X9DRJNN&DKD6VP6AF&ts:1655613103.610449][Slack message in #Slackbot at [14:31]: Feeling great!]], which works great.

If you can help me here, I'd greatly appreciate it 😅

@ag91
Copy link
Owner

ag91 commented Jun 19, 2022

right, sorry! I forgot to mention that emacs-slack needed an edit: ag91/emacs-slack@1f2ae6c

Could you try to define the following function and try again?

(defun slack-message-notify-alert (message room team)
  (if (slack-message-notify-p message room team)
      (let ((team-name (oref team name))
            (room-name (slack-room-name room team))
            (text (with-temp-buffer
                    (goto-char (point-min))
                    (insert (slack-message-to-alert message team))
                    (slack-buffer-buttonize-link)
                    (buffer-substring-no-properties (point-min)
                                                    (point-max))))
            (user-name (slack-message-sender-name message team)))
        (if (and (eq alert-default-style 'notifier)
                 (slack-im-p room)
                 (or (eq (aref text 0) ?\[)
                     (eq (aref text 0) ?\{)
                     (eq (aref text 0) ?\<)
                     (eq (aref text 0) ?\()))
            (setq text (concat "\\" text)))
        (alert (if (slack-im-p room) text (format "%s: %s" user-name text))
               :icon slack-alert-icon
               :title (if (slack-im-p room)
                          (funcall slack-message-im-notification-title-format-function
                                   team-name room-name (slack-thread-message-p message))
                        (funcall slack-message-notification-title-format-function
                                 team-name room-name (slack-thread-message-p message)))
               :category 'slack))))
               :category 'slack
               :data (list
                      :team-id (slack-team-id team)
                      :room-id (oref room id)
                      :room-name (slack-room-name room team)
                      :team-name (oref team name)
                      :ts (slack-ts message)
                      :formatted-ts (ts-format "[%H:%m]" (ts-now)))))))

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

2 participants