mediawiki-slack icon indicating copy to clipboard operation
mediawiki-slack copied to clipboard

No protocol in URL in Slack message

Open ghost opened this issue 9 years ago • 2 comments

Under Slack, I received messages like this : <//wiki.domain.com/wiki/index.php/pageName>_​ modified by ​_userName*​.

The protocol was missing in the URL (probably because of a specific configuration on my wiki).

I modified the extension's code in Slack.hooks.php, line 66 from : // Build the message we're going to post to Slack. $message = '<'.SlackHooks::encodeSlackChars($wikiPage->getTitle()->getFullURL()) .'|'.SlackHooks::encodeSlackChars($wikiPage->getTitle()).'> ' .$verb.' by *';

To : // Build the message we're going to post to Slack. $message = '<'.SlackHooks::encodeSlackChars($wikiPage->getTitle()->getFullURL('', false, PROTO_CURRENT)) .'|'.SlackHooks::encodeSlackChars($wikiPage->getTitle()).'> ' .$verb.' by *';

And it solved my problem. I now get proper Slack messages. I did not investigate if this change could break the extension on other wikis so I create an issue instead of a pull request...

ghost avatar Jan 12 '16 18:01 ghost

Is $wgServer set correctly in your LocalSettings.php?

grundleborg avatar Jan 12 '16 20:01 grundleborg

Hum you're right it's: $wgServer = "//wiki.server.com"; $wgCanonicalServer = "https://wiki.server.com";

But this config should be supported: https://www.mediawiki.org/wiki/Manual:$wgServer https://www.mediawiki.org/wiki/Manual:$wgCanonicalServer

ghost avatar Jan 13 '16 09:01 ghost