dylex / slack-libpurple

Slack module for libpurple
GNU General Public License v2.0
276 stars 38 forks source link

Support Calls #166

Closed DanielSiepmann closed 2 years ago

DanielSiepmann commented 2 years ago

Hi,

I've just started to use this plugin with pidgin and tried the video calls. I would like to start a call and use calls within pidgin. But I would understand if that's to much.

Right now I receive an URL if someone starts a call, but the URL sems wrong. It is like https://workspace.slack.com/call/<call-id> but it seems they need to be like https://app.slack.com/free-willy/<im-id>/<call-id> where is the channel or user id.

I couldn't find anything related within the code and expect slack itself to send this url. Maybe we could transform this URL?

DanielSiepmann commented 2 years ago

I've added a PR which converts the incoming broken URLs. Next up would be a button to start a call, if possible. Not sure if I am able to do that.

DanielSiepmann commented 2 years ago

I've started to read the plugin development how to as well as the source code. Looks like a new custom command /call would to the job, which calculates the call URL from account and conversation and posts it via API. That way Slack web app and native clients will show a proper call while purple will retrieve the message and show the native link which could be opened within the browser.

I'll see whether I can implement that during the upcoming days.

DanielSiepmann commented 2 years ago

Hey, @EionRobb can you help me out? I got it working but kept searching 2 hours to access the slack user id and can't find a way.

That's my current code which is working fine for group chats, but not for Ims as the obj->id is wrong. I need the one saved within the buddy within blist.xml but can't find a proper way to fetch this value. Any hints?

static PurpleCmdRet cmd_startcall(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) {
    SlackAccount *sa = get_slack_account(conv->account);
    if (!sa)
        return PURPLE_CMD_RET_FAILED;

    SlackObject *obj = slack_conversation_get_conversation(sa, conv);
    if (!obj) {
        return PURPLE_CMD_RET_FAILED;
    }

    // TODO: proper chat id for IMs
    // That's the one attached to the buddy as "slack"
    gchar *url = g_strconcat("https://app.slack.com/free-willy/", sa->team.id, "/", obj->id, NULL);
    slack_write_message(sa, obj, url, PURPLE_MESSAGE_SEND);
    g_free(url);

    return PURPLE_CMD_RET_OK;
}
DanielSiepmann commented 2 years ago

Looks like all I was looking for was: slack_conversation_id(obj). PR incoming.

DanielSiepmann commented 2 years ago

I'd say can be closed once the two related PRs got merged.