Nxt Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Nxt Client 1.11.5 - NEW RELEASE: Ardor 2.0.3e TestNet IS LAUNCHED!

Pages: [1]

Author Topic: Slackchat Plugin  (Read 1599 times)

devlux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 308
    • View Profile
    • Gemspace
  • Karma: +67/-2
Slackchat Plugin
April 21, 2016, 05:29:07 am

Slackchat plugin is now functional.
You should go to your NXT html/ui/plugins directory
then
Code: [Select]
git clone --recursive https://github.com/valortech/common_components.git
git clone --recursive https://github.com/valortech/slackchat.git

If plugins are enabled then as soon as you log into NXT you will be redirected to slack for authorization.  You need to grant it permissions, then you'll be redirected to the NXT landing page.  You'll need to log into NXT, but that will be the last time.  After that step is done, everything should just work.

Note that I ONLY tested this on the most recent versions of FireFox and Chrome.  I didn't even try any other browsers but there is no reason a modern up to date browser would have problems with this code.
Evolution NEXT D.A.C.
NXTAE:3385321989487982138 (EVOLVE)

websioux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 282
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
  • Karma: +58/-1
Re: Slackchat Plugin
April 21, 2016, 07:56:54 am

Congrat but what does it do ? Put Nxt slack into Nxt client UI ? Probably yes, and it would be a good idea.

Do you considered to extend to any slack ? or multi slack ? It looks like a great example that others can use to integrate any other stuff they like.
The Nxt UI would be plugin tuned to become a great co-working environment.



Secret Miner <= communicate with style | NotBot <= timestamp digital docs

devlux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 308
    • View Profile
    • Gemspace
  • Karma: +67/-2
Re: Slackchat Plugin
April 21, 2016, 08:52:15 am

Congrat but what does it do ? Put Nxt slack into Nxt client UI ? Probably yes, and it would be a good idea.

Do you considered to extend to any slack ? or multi slack ? It looks like a great example that others can use to integrate any other stuff they like.
The Nxt UI would be plugin tuned to become a great co-working environment.

Hi, the pedigree on this plugin is a bit strange.  It's the result of the "telegram" plugin bounty and it's the first 2/3rds

What happened is that about halfway through developing the telegram plugin, I realized that there were problems with telegram, mostly relating to security issues.

As I mentioned in the telegram thread.  These aren't problems with telegram per se.  If you're swapping cat pix with your buddies it's just fine.  However the way telegram does some things, leaves open the possibility that a specially constructed message could disclose your private key and at the time I didn't see a clean way to fix that.

I decided to stop work and offer a few alternatives that could be more secure. 

I put it to a vote of the people who paid the bounty.  2/3rds voted for slack.

So this plugin is JUST exactly as you described it.  It's a bit primitive, It's meant more as a proof of concept than anything.  It does expose the entire slack API though and that API is exposed to the DOM under a "slack.whatever" namespace.  So anything you can do with slack you can build and extend using this plugin as a base.  Right now it's chat only and only in #general.

As it turns out, during the voting, the other 1/3rd of bounty contributors actually upped the stake on the bounty to get SOME level of Telegram integration.

So we now have a situation where 1 bounty can fairly compensate for 2 plugins.  Normally this wouldn't be the case, but most of the work on these plugins is related to getting Angular and other shared UI components to play nicely with NRS and with eachother.

Nevertheless this put me in a situation.
Some people wanted ANY chat they could get, but decided that slack is useful because it's a quick and easy way to get support.
The others wanted "telegram" specifically.  So this is the "slack half" of the telegram bounty :)

I believe I've managed to solve the security issue with telegram by taking a different approach.  So now I'm debugging that and will have it up in a few days assuming my allergies don't try to kill me again :D
« Last Edit: April 21, 2016, 09:02:31 am by devlux »
Evolution NEXT D.A.C.
NXTAE:3385321989487982138 (EVOLVE)

websioux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 282
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
  • Karma: +58/-1
Re: Slackchat Plugin
April 21, 2016, 10:01:35 am

Great, the Nxt plugin sphere needs good bricks to play with.
Secret Miner <= communicate with style | NotBot <= timestamp digital docs

MrCluster87

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 839
    • View Profile
    • youtube
  • Karma: +81/-3
Re: Slackchat Plugin
April 24, 2016, 09:16:35 pm

Hey this is the summary of slackchat plug-in testing on nxter slack channel for you're reference.

1) after installing git: sudo apt-get install git

and 2) the plug in, 3) then you should log-in a slack channel and get the authorisation (both from you and the channel administrator).

So once you link to a channel you cannot add another one and you have to write on slack sub-forum like #general or #whaterver and then you can log out and continue from where you left inside the NRS.

You cannot write in bold or emoticons or click external link from NRS,

But actually it works  ;)

http://imgur.com/a/yso4X

devlux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 308
    • View Profile
    • Gemspace
  • Karma: +67/-2
Re: Slackchat Plugin
April 24, 2016, 10:34:21 pm

Hey this is the summary of slackchat plug-in testing on nxter slack channel for you're reference.

1) after installing git: sudo apt-get install git

and 2) the plug in, 3) then you should log-in a slack channel and get the authorisation (both from you and the channel administrator).

So once you link to a channel you cannot add another one and you have to write on slack sub-forum like #general or #whaterver and then you can log out and continue from where you left inside the NRS.

You cannot write in bold or emoticons or click external link from NRS,

But actually it works  ;)

http://imgur.com/a/yso4X

Yes those limitations are intentional.  You'd have to parse HTML to handle it and that runs the risk of exposing your wallet info since everything has to share the same DOM.

Although I can add a channel list if you'd like.  I had intended it more for a quick support tool others could build from.
Evolution NEXT D.A.C.
NXTAE:3385321989487982138 (EVOLVE)

devlux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 308
    • View Profile
    • Gemspace
  • Karma: +67/-2
Re: Slackchat Plugin
April 28, 2016, 07:43:08 am

I've put up a new version.  Make sure to do a git pull on both common components and the slackchat.  Then also clear all cookies and cache from your browser.
Improvements are that it scrolls properly now instead of extending into infinity.  I also added a toast mechanism so you can minimize chat, go about your business and be notified when someone is trying to talk, or they enter and leave the room.
Final change is that it will default to general channel.  I added a channel list as well and clicking on channels should work, but for some reason the channel list is not showing up.  I think I'll leave it alone at this point and leave fixing channels and contacts as an exercise for future people.
Evolution NEXT D.A.C.
NXTAE:3385321989487982138 (EVOLVE)

MrCluster87

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 839
    • View Profile
    • youtube
  • Karma: +81/-3
Re: Slackchat Plugin
April 28, 2016, 07:35:49 pm

Ok, much better then the previews version. Someone authorize it over nxtchat channel!!

Here the tutorial: https://www.youtube.com/watch?v=qM63bh4uuk8

Damelon

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2291
    • View Profile
    • Nxt Inside
  • Karma: +789/-53
Re: Slackchat Plugin
April 28, 2016, 09:16:53 pm

Any way to get this plugin easily on a Windows box? :)
Member of the Nxt Foundation | Donations: NXT-D6K7-MLY6-98FM-FLL5T
Join Nxt Slack! https://nxtchat.herokuapp.com/
Founder of Blockchain Workspace | Personal Site & Blog

devlux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 308
    • View Profile
    • Gemspace
  • Karma: +67/-2
Re: Slackchat Plugin
April 29, 2016, 01:28:37 pm

@MrCluster87 Nice video but there seems to be a couple of problems.
Firstly, the slackchat plugin has a hardcoded key that is specific to nxtchat.slack so when you pointed it to nxter it never properly authed, or at least it shouldn't have.  If it did then we should probably notify slack because that's not supposed to happen.  Easiest way to validate if that's the case is to check the nxter slack chat and see if your message posted.  If it did then this is some sort of security wierdness with slack.  But it may not be a problem, since you are a member of both nxter & nxtchat.  I honestly don't know how slack's security treats a situation like that.

Secondly the thing should have toasted both your login and your message, it only does the toast once it gets confirmation from the server that the message has been sent or arrived.  However toasting occurs before the update to the chatbox.  So something wen't really wonky there.

Try clearing your cookies & cache and redoing the auth step, but make sure to auth against nxtchat, just to be certain.  Each channel does have a unique ID, on login we get a list of all channels you as a user can subscribe to.  We're only looking for the first one names "general" and selecting that since as you can see the channel list display still isn't working correctly for whatever reason.

@Damelon to answer your question you can get a zip of any github repo.
Just download these, copy them to your plugins directory and extract them there, make sure they extract into directories called common_components and slackchat.  You should see a manifest.json file in the top level of each directory.
Code: [Select]
https://github.com/valortech/common_components/archive/master.zip
Code: [Select]
https://github.com/valortech/slackchat/archive/master.zip
Also Damelon can you please make sure that the plugin is an authorized app for the nxtchat team.  You are literally the only person who can do that authorization.  Thanks!

Ok guys so to explain what is going on in his video.  You have to login to NXT, to enable plugins (after downloading them), then logout. 

After you log out the first time I highly recommend you press F5 to force a refresh.  Certain bits can be served stale if you don't.  You only need to do that once and then again each time you update the plugins.

Once you log into NXT the plugin will whip you over to slack where you log into slack and allow the plugin to post as you.  This creates a temporary key which is valid for about 30 seconds.  That key is sent back to NXT and saved in the NXT prefs, but since NXT doesn't allow us to get at the params, we cheat by making a custom landing page then uses some JS wizardry.

We only have about 30 seconds to get that temporary key upgraded before slack will revoke it.  Thus a custom landing page with an async request for upgrade, once the upgraded "permanent key" is returned we  store it in the NXT browser cache.

This is what that black and white landing page is all about. 

After this step is done, then you are automatically redirected to NXT, which of course wants you to login again.
This forces the plugin to reload.  The plugin checks for the final slackauth key and if it's valid you'll get a toast mentioning you are logged into chat.
The connecting message appears oddly a bit late in the process, if you see it then you are already "connected", but the actual auth check against slack is still pending.  There "should" be a message that the key is accepted, but slack doesn't always give us that message.  Many times we only find out that a key is invalid / expired / rejected when we go to send a message.  We use the realtime messaging API to receive messages, but we use the regular API for posting them.  This forms a roundtrip that every message must take before it will show up in the chat box.  So if you type a message and it doesn't show up then that means something happened to expire out your key.  You'll need to clear your cookies and cache and restart the auth process.
Evolution NEXT D.A.C.
NXTAE:3385321989487982138 (EVOLVE)
Pages: [1]