Giter Site home page Giter Site logo

emedvedev / slackin-extended Goto Github PK

View Code? Open in Web Editor NEW
162.0 4.0 85.0 3.19 MB

Public Slack organizations made easy (extended fork of rauchg/slackin)

Home Page: https://slackin-extended.emedvedev.now.sh

License: MIT License

JavaScript 60.80% CSS 4.81% Shell 6.07% Dockerfile 0.19% SCSS 17.81% Pug 8.64% Mustache 1.66% Procfile 0.02%
slack slackin

slackin-extended's Introduction

npm version Build Status MIT License

Features

Slackin-extended is a more customizable and extendable fork of the original slackin.

  • A landing page you can point users to fill in their emails and receive an invite (https://slack.yourdomain.com)
  • An <iframe> badge to embed on any website that shows connected users in realtime with socket.io.
  • A SVG badge that works well from static mediums (like GitHub README pages)
  • Abuse prevention via Google reCAPTCHA, including Invisible reCAPTCHA.
  • Color scheme customization on both the landing page and the badge.

Check out the Demo, which is deployed live from the master branch. For the list of changes in slackin-extended see HISTORY.md.

Disclaimer: this project is not affiliated with Slack. The Slack logo and Slack API are copyright Slack Technologies, Inc.

Installation

Heroku

Deploy

Now

Set up Now on your device and run it! If you don't have an .env file for your Now deployment (see environment variables and secrets), you can just set the two required parameters through now secrets:

git clone https://github.com/emedvedev/slackin-extended.git
now secrets add slack-subdomain "myslack"
now secrets add slack-api-token "xoxb-YOUR-SLACK-TOKEN"
now slackin-extended

Fly.io

Set up Fly.io to run slackin-extended. You'll need to set a specific port to play well with the default fly port config.

git clone https://github.com/emedvedev/slackin-extended.git
flyctl secrets set SLACK_SUBDOMAIN="myslack" SLACK_API_TOKEN="xoxb-YOUR-SLACK-TOKEN" SLACKIN_PORT=8080
flyctl deploy

Docker

The Docker container is available on Docker Hub: emedvedev/slackin-extended.

npm

To host Slackin-extended yourself, install it via npm and launch it on your server:

npm install -g slackin-extended
slackin "workspace-id" "your-slack-token"

Usage

Badges

Realtime (demo)

<script async defer src="https://slack.yourdomain.com/slackin.js"></script>
<!-- append "?large" to the URL for the large version -->

SVG (demo)

<img src="https://slack.yourdomain.com/badge.svg">

By default, the badge background color will be set to your accent color, but you can customize both background and text colors through the query string:

<img src="https://slack.yourdomain.com/badge.svg?bg=e01563&fg=ffffff">

Parameters

Every CLI parameter, including mandatory arguments (workspace ID and token), can alternatively be configured through environment variables.

Flag Short Environment variable Default Description
Positional 1 SLACK_SUBDOMAIN Required Slack workspace ID (https://**{this}**.slack.com)
Positional 2 SLACK_API_TOKEN Required API token
--port -p SLACKIN_PORT 3000 Port to listen on
--hostname -h SLACKIN_HOSTNAME '0.0.0.0' Hostname to listen on
--channels -c SLACKIN_CHANNELS '' One or more comma-separated channel names to allow single-channel guests
--emails -e SLACKIN_EMAILS '' Restrict sign-up to a list of emails (comma-separated; wildcards are supported)
--interval -i SLACKIN_INTERVAL 60000 How frequently (ms) to poll Slack
--path -P SLACKIN_PATH / Path to serve slackin under
--silent -s SLACKIN_SILENT false Do not print out warnings or errors
--cors -x SLACKIN_CORS false Enable CORS for all routes
--analytics -a SLACKIN_ANALYTICS '' Google Analytics ID
--recaptcha-secret -R RECAPTCHA_SECRET '' reCAPTCHA secret
--recaptcha-sitekey -K RECAPTCHA_SITEKEY '' reCAPTCHA sitekey
--recaptcha-invisible -I RECAPTCHA_INVISIBLE '' Use invisible reCAPTCHA
--theme -T SLACKIN_THEME light Color scheme to use, light or dark
--accent -A SLACKIN_ACCENT #e01563 for light, #9a0e44 for dark Accent color to use instead of a theme default
--coc -C SLACKIN_COC '' Full URL to a CoC that needs to be agreed to
--css -S SLACKIN_CSS '' Full URL to a custom CSS file to use on the main page
SLACKIN_PAGE_DELAY 0 Delay (ms) between Slack API requests (may be required for large workspaces that hit the rate limit)
SLACKIN_PROXY false Trust proxy headers (only use if Slackin is served behind a reverse proxy)
SLACKIN_HTTPS_REDIRECT '' If a domain name is specified in this parameter and SLACKIN_PROXY is set to true, Slackin will redirect requests with x-forwarded-proto === 'http' to https://<SLACKIN_HTTPS_REDIRECT>/<original URL>
SLACKIN_LETSENCRYPT '' Let's Encrypt challenge response

Alternatively, you can specify the configuration parameters in a dotenv file: create a .env file in the root directory of your project and add environment-specific variables on new lines in the form of NAME=VALUE. For example:

SLACK_SUBDOMAIN=mysubdomain
SLACK_API_TOKEN=SLACK-API-TOKEN
SLACKIN_THEME=dark

Extras

Tips and tricks

  • Please use reCAPTCHA for your Slack to avoid request flooding by spambots. Here is where to get your secret and sitekey. Make sure you choose a v3 API key.

  • Invisible reCAPTCHA is recommended for the realtime badge users, as the regular CAPTCHA challenge is broken inside the iframe that opens on badge click.

  • You can find or generate your API test token at api.slack.com/web. Important notes:

    • you need a legacy token
    • the user you use to generate the token must be an admin. You need to create a dedicated @slackin-inviter user (or similar), mark that user an admin, and use a test token from that dedicated admin user. Note that test tokens have actual permissions so you do not need to create an OAuth 2 app. Also check out the Slack docs on generating a test token.
  • Important: If you use Slackin in single-channel mode, you'll only be able to invite as many external accounts as paying members you have times 5. If you are not getting invite emails, this might be the reason. Workaround: sign up for a free org, and set up Slackin to point to it (all channels will be visible).

Development

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Uninstall slackin if it's already installed: npm uninstall -g slackin-extended
  3. Link it to the global module directory: npm link
  4. Run it locally with npm run dev, after setting up the needed environment variables

Yay! Now can use the slackin command everywhere.

Extending templates and themes

If changing accent colors and switching between light/dark themes isn't enough for you, all templates are stored inside views/ and can be easily modified. Stylesheets are stored in scss/, and both themes have a documented example of colors, variables and additional styles necessary to create your own.

If you end up creating another theme, you're more than welcome to submit a PR!

API

Loading slackin will return a Function that creates a HTTP.Server instance:

const slackin = require('slackin-extended');

slackin({
  token: 'SLACK-API-TOKEN', // reqired
  org: 'your-slack-subdomain', // required
  interval: 60000, // polling interval for Slack servers
  path: '/some/path/you/host/slackin/under/', // defaults to '/'
  cors: false, // set to "true" to enable CORS
  recaptcha: {
    secret: 'RECAPTCHA-SECRET', // reCAPTCHA secret
    sitekey: 'RECAPTCHA-SITEKEY', // reCAPTCHA sitekey
    invisible: true, // enable Invisible reCAPTCHA
  },
  analytics: 'GOOGLE-ANALYTICS-ID', // Google Analytics ID
  theme: 'light', // color scheme: "light" or "dark"
  accent: 'teal', // accent color (for buttons, text accents, etc.)
  css: 'https://example.org/slackin-extra.css', // external CSS file to include
  channels: 'community-public,testing', // for single-channel mode
  emails: '[email protected],[email protected],*@johnandjane.com', // email whitelist
  coc: 'https://example.org/code-of-conduct', // code of conduct link
  proxy: false, // set to "true" if Slackin is set up behind a reverse proxy
  redirectFQDN: 'slack.myorg.com', // redirect requests with x-forwarded-proto === 'http' to this domain
  letsencrypt: 'LETSENCRYPT-CHALLENGE', // Let's Encrypt challenge
  silent: false, // suppress warnings
  server: http.Server(), // optional, allows passing in an existing http server object
}).listen(3000)

This will show response times from Slack and how many online users you have on the console. The returned http.Server has an app property that is the express application that you can define or override routes on.

All the metadata for your organization can be fetched via a JSON HTTP request to /data.

slackin-extended's People

Contributors

afeld avatar balupton avatar darron avatar dependabot-preview[bot] avatar dependabot[bot] avatar designorant avatar elliottsj avatar emedvedev avatar evilrabbit avatar hardeep avatar heyjohnford avatar jomo avatar jpoon avatar jszwedko avatar jtatum avatar laughinghan avatar leo avatar limulus avatar lvnilesh avatar madebymike avatar maxwofford avatar mcmahoniel avatar mlissner avatar nickstenning avatar rauchg avatar raysarebest avatar rymohr avatar ssandler avatar toolmantim avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

slackin-extended's Issues

Move logos from CSS to HTML

This should improve performance since we won't need to download and parse the CSS to display the logos. Should be accompanied with width and height attributes (48 for both).

Doesn't seem to work with heroku

-----> Node.js app detected
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
-----> Installing binaries
       engines.node (package.json):  ^8.0.0
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version ^8.0.0...
       Downloading and installing node 8.11.3...
       Using default npm version: 5.6.0
-----> Restoring cache
       Skipping cache restore (new-signature)
-----> Building dependencies
       Running heroku-prebuild
       
       > [email protected] heroku-prebuild /tmp/build_507a77a0924135f75c8c8242fa367025
       > npm install --only=dev
       
       
       > [email protected] install /tmp/build_507a77a0924135f75c8c8242fa367025/node_modules/node-sass
       > node scripts/install.js
       
module.js:549
    throw err;
    ^
Error: Cannot find module 'inherits'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/tmp/build_507a77a0924135f75c8c8242fa367025/node_modules/true-case-path/node_modules/glob/glob.js:46:16)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.ksUCf/_logs/2018-07-22T23_39_04_677Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] heroku-prebuild: `npm install --only=dev`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] heroku-prebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.ksUCf/_logs/2018-07-22T23_39_04_791Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       If you're stuck, please submit a ticket so we can help:
       https://help.heroku.com/
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

Allow users to customize favicon.ico

I really need to fix #20 otherwise I'm having trouble testing this package.

We also need to look into #52 and #63 because development would be a lot easier. And ideally we need a live preview of the app.

I know I'm asking for a lot, just thinking out loud :)

Tighten HTTP headers

I personally use https://github.com/helmetjs/helmet, but we try doing it manually if you think it'd be better. I personally don't try to reinvent the wheel when possible :)

If we go with the helmet approach we might want to disable HSTS so that we don't introduce broken sites for people.

Ideally, controlling the middlewares like favicon, helmet, cache etc should be configurable so that everyone does what they need to and so that we don't have another thing to worry about, apart from some sane defaults :)

Slack API token using App

Hello,
I found your solution few days ago to provide a good solution to invite new user to a slack community.

After some reading I tried to create an App to get a working token (from this URL)

https://api.slack.com/apps/XXXX/install-on-team?

But this Token do not work.

Notes:
I've added some scopes to this app such as admin.invites.write.

Is App integration working or only generated invite url now work ?

Analytics code being added as plain text, rather than in script tag

Adding SLACKIN_ANALYTICS caused the code to be output in the body of the page as plain text - I think because the script tag is closed prematurely.

function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-1170467-12');</head><body>```

I think the `{gaID}` should also be replaced by `#{analytics}`

500 internal server error

Sorry for posting here, but I cannot access your site!
image
Here is something that might help:

500: INTERNAL_SERVER_ERROR
Code: FUNCTION_INVOCATION_FAILED
ID: sfo1::n7knp-1614042256050-f8ab90846f60

res.body is undefined

@emedvedev I was trying to register on the demo Slack (so that maybe we can chat in real time :P) but I get this and nothing happens

TypeError: res.body is undefined client.js:55:11
    invite https://slackin-extended.emedvedev.now.sh/assets/client.js:55
    callback https://slackin-extended.emedvedev.now.sh/assets/superagent.js:1723
    Request https://slackin-extended.emedvedev.now.sh/assets/superagent.js:1548
    emit https://slackin-extended.emedvedev.now.sh/assets/superagent.js:1080
    onreadystatechange https://slackin-extended.emedvedev.now.sh/assets/superagent.js:1817

I believe it's an issue with the deployment, but regardless... The POST response seems to be

{"msg":"not_allowed_token_type"}

So, I guess we need to tweak the client JS too so that we catch this properly. Not sure if it worked before with the old superagent client version or if it's a new regression from #59.

Might be worth just switching to XHR sooner than later while at it, assuming it worked before #59.

Unhandled promise rejection

I was running this locally and when I hit the too many requests error I got the following call stack:

  slackin:slack Error: undefined +5ms
(node:5128) UnhandledPromiseRejectionWarning: TypeError: this.sleep is not a function
    at SlackData.fetchUserCount (C:\Users\xmr\Desktop\slackin-extended\lib\slack.js:91:24)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:5128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5128) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I'm not sure if this happens or has happened in the deployed version but nonetheless, there shouldn't be an unhandled Promise rejection, right?

PS. I still see those spikes in response time in the production app :/

Update Node.js to 14.x

Node.js 14.x has some nice improvements and it's the current LTS: https://nodejs.org/en/about/releases/

I'm opening this issue so that the version is updated for all deployments. I only deploy on Heroku and I'm using 14.x since the beginning I switched to slackin-extended, but this should be done for all deployments like Docker, Azure etc

Remove the count from slackin page or a daily update cron job

The count on the slackin landing page is behind the actual user count and we have to continually redeploy the instance in order to get it to update

It would be great if there were a config option to either not show the count or run a daily cron job to update the count

Slack deprecating the users.admin.invites api

I have been looking at hosting an instance slack recommends using their new apps for creating tokens.

I tried creating one but seems like I can't add scope admin.users.invites for free accounts it is only available for enterprise users.

Slackin might stop working once they complete phase out the legacy api.

Heroku deployment broken

Hi there, thanks for this great project and forking the original!

When clicking to deploy it to Heroku, you get the following error

The content of app.json is not valid; please see app.json Schema for more information.

Can't install: no gulpfile found

Hello,

I tried this package as a replacement for slackin, but I am unable to install it using npm:

npm ERR! Linux 4.4.0-97-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "slackin-extended"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `gulp`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'gulp'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the slackin-extended package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs slackin-extended
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls slackin-extended
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/slackin/npm-debug.log

Could you see if you can move all those gulp dependencies into devDependencies? I don't think those should be needed on a published package :) Would make installing it much faster as well.

Thank you for your efforts!

Now v2 issues

I think there's some bug with cold start, because the first launch of every Now deployment always gives 502. After refresh everything starts working.

Insufficient reCAPTCHA response verification

It looks like reCAPTCHA is not correctly implemented and the protection can be easily bypassed. Not providing exact details here to not expose organizations that are using this fork to bot attacks, but the bypass is trivial and has been confirmed in testing. Please make sure to correctly verify the value of g-recaptcha-response when sending invites.

Npm install can break server-side path to client-side dependency /assets/superagent.js

The client-side dependency /assets/superagent.js is given special server-side path treatment in index.js.

On my system /assets/superagent.js returns HTTP error 404 and breaks slackin-extended client-side. This is due to (changes in) how npm install places dependencies, which may be optimized between packages in the same package.json.

Versions

Am running slightly older versions due to apt on Debian 10 Buster.

node --version
v10.15.2
npm --version
6.14.4
Paths
npm ls superagent
[email protected] .../slackin.joelpurra.com/public_html
└─┬ [email protected]
  └── [email protected] 
ls --format=long --directory ./node_modules/{slackin-extended,superagent}
drwxr-xr-x 1 root root 116 Apr  8 16:56 ./node_modules/slackin-extended
drwxr-xr-x 1 root root 282 Apr  8 16:56 ./node_modules/superagent

Perhaps something like resolve-pkg could be used in the short-term, but replacing superagent with something else might be a better long-term solution. See also #86.

Originally posted by @joelpurra in #86 (comment)

Broken on now.sh?

I've tried to install it through now as suggested. The original slackin worked fine and the deployment seems to have gone ok:

> Using Node.js 8.9.4 (requested: `^8.0.0`)
> Ready! https://slackin-extended-kazttitkgq.now.sh (copied to clipboard) [37s]
> Synced 1 file (1.74KB) [0ms]
> Initializing…
> Building
> ▲ npm install
> ⧗ Installing 28 main dependencies…
> ✓ Installed 865 modules [11s]
> ▲ npm run build
> > [email protected] build /home/nowuser/src
> > gulp
> [04:26:08] Failed to load external module @babel/register
> [04:26:08] Requiring external module babel-register
> [04:26:09] Using gulpfile ~/src/gulpfile.babel.js
> [04:26:09] Starting 'transpile'...
> [04:26:09] Starting 'assets'...
> [04:26:09] Starting 'sass'...
> [04:26:09] Finished 'assets' after 29 ms
> [04:26:09] Finished 'sass' after 30 ms
> [04:26:09] Finished 'transpile' after 494 ms
> [04:26:09] Starting 'default'...
> [04:26:09] Finished 'default' after 37 μs
> ▲ npm start
> > [email protected] start /home/nowuser/src
> > ./bin/slackin
> 2018-02-05T04:26:12.132Z slackin:main Theme: light
> 2018-02-05T04:26:12.141Z slackin:main Establishing connection with Slack
> 2018-02-05T04:26:12.182Z slackin:slack Fetching data from Slack
> 2018-02-05T04:26:12.215Z slackin:main Listening on 0.0.0.0:3000
> 2018-02-05T04:26:12.566Z slackin:slack Attempt failed, will retry
> Deployment complete!

However there seems to be a problem with the path?

Error: Failed to lookup view "main" in views directory "/home/nowuser/src/views"
    at Function.render (/home/nowuser/src/node_modules/express/lib/application.js:580:17)
    at ServerResponse.render (/home/nowuser/src/node_modules/express/lib/response.js:1008:7)
    at /home/nowuser/src/dist/index.js:192:29
    at Layer.handle [as handle_request] (/home/nowuser/src/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/nowuser/src/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/nowuser/src/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/nowuser/src/node_modules/express/lib/router/layer.js:95:5)
    at /home/nowuser/src/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/nowuser/src/node_modules/express/lib/router/index.js:335:12)
    at next (/home/nowuser/src/node_modules/express/lib/router/index.js:275:10)

demo url: https://slackin-extended-kazttitkgq.now.sh/

Heroku app crash at launch

Hi @emedvedev

First of all, thanks for this updated fork :-)

I've tried to use it with the Heroku button, after settings all env var according to documentation. But the application keep crashing at start.

Here is the logs:

2020-03-10T10:34:47.403698+00:00 app[web.1]: > [email protected] start /app

2020-03-10T10:34:47.403698+00:00 app[web.1]: > cross-env-shell node ./bin/slackin $SLACK_SUBDOMAIN $SLACK_API_TOKEN --coc \"$SLACKIN_COC\" --channels \"$SLACKIN_CHANNELS\"

2020-03-10T10:34:47.403699+00:00 app[web.1]: 

2020-03-10T10:34:47.873923+00:00 app[web.1]: (node:31) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'status' of undefined

2020-03-10T10:34:47.873925+00:00 app[web.1]:     at SlackData.fetchUserCount (/app/lib/slack.js:89:30)

2020-03-10T10:34:47.873926+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:68:7)

2020-03-10T10:34:47.874169+00:00 app[web.1]: (node:31) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

2020-03-10T10:34:47.874255+00:00 app[web.1]: (node:31) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

2020-03-10T10:34:47.877020+00:00 app[web.1]: /app/lib/slack.js:36

2020-03-10T10:34:47.877021+00:00 app[web.1]:         const { team } = res.body;

2020-03-10T10:34:47.877021+00:00 app[web.1]:                              ^

2020-03-10T10:34:47.877022+00:00 app[web.1]: 

2020-03-10T10:34:47.877022+00:00 app[web.1]: TypeError: Cannot read property 'body' of undefined

2020-03-10T10:34:47.877022+00:00 app[web.1]:     at request.get.query.end (/app/lib/slack.js:36:30)

2020-03-10T10:34:47.877023+00:00 app[web.1]:     at Request.callback (/app/node_modules/superagent/lib/node/index.js:728:3)

2020-03-10T10:34:47.877023+00:00 app[web.1]:     at ClientRequest.req.once.err (/app/node_modules/superagent/lib/node/index.js:647:10)

2020-03-10T10:34:47.877024+00:00 app[web.1]:     at Object.onceWrapper (events.js:286:20)

2020-03-10T10:34:47.877024+00:00 app[web.1]:     at ClientRequest.emit (events.js:198:13)

2020-03-10T10:34:47.877024+00:00 app[web.1]:     at TLSSocket.socketErrorListener (_http_client.js:401:9)

2020-03-10T10:34:47.877025+00:00 app[web.1]:     at TLSSocket.emit (events.js:198:13)

2020-03-10T10:34:47.877025+00:00 app[web.1]:     at emitErrorNT (internal/streams/destroy.js:91:8)

2020-03-10T10:34:47.877025+00:00 app[web.1]:     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)

2020-03-10T10:34:47.877025+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:63:19)

2020-03-10T10:34:47.886617+00:00 app[web.1]: npm ERR! code ELIFECYCLE

2020-03-10T10:34:47.887006+00:00 app[web.1]: npm ERR! errno 1

2020-03-10T10:34:47.888225+00:00 app[web.1]: npm ERR! [email protected] start: `cross-env-shell node ./bin/slackin $SLACK_SUBDOMAIN $SLACK_API_TOKEN --coc \"$SLACKIN_COC\" --channels \"$SLACKIN_CHANNELS\"`

2020-03-10T10:34:47.888331+00:00 app[web.1]: npm ERR! Exit status 1

2020-03-10T10:34:47.888535+00:00 app[web.1]: npm ERR! 

2020-03-10T10:34:47.888648+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.

2020-03-10T10:34:47.888748+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Don't know if I missed something or not ?

socket.io 502s

This is noticeable on the demo site, see the browser console

socket.io updates

  • I think we should load this from node_modules too; not sure how easy it'll be since iframe.js makes a new script call. We should probably take into account the data.path variable
  • We should use the slim version
  • We should see if it's safe to update to 2.x
  • see if we can make the whole real-time updates optional

Oh, and make these changes in small batches :)

Heroku: Cannot read property 'body' of null

Aftwer typing in the email and submitting the form I see a javascript error. The button is greyed out and nothing happens. (A slack invite is sent out though!)
Uncaught TypeError: Cannot read property 'body' of null at client.js:55 at Request.callback (superagent.js:1723) at Request.<anonymous> (superagent.js:1550) at Request.Emitter.emit (superagent.js:1080) at XMLHttpRequest.xhr.onreadystatechange (superagent.js:1817)

function invite(chan, coc, email, gcaptcha_response_value, fn) {
  request
    .post(data.path + 'invite')
    .send({
      'g-recaptcha-response': gcaptcha_response_value,
      coc: coc,
      channel: chan,
      email: email
    })
    .end(function (res) {
      if (res.body.redirectUrl) {
        window.setTimeout(function () {
          topLevelRedirect(res.body.redirectUrl)
        }, 1500)
      }
      if (res.error) {
        return fn(new Error(res.body.msg || 'Server error'))
      }
      fn(null, res.body.msg)
    })
}

Accepting CoC never succeeds

After setting a link to a CoC, whenever a potential user requests an invite, they will always get an error message saying "Agreement to CoC is mandatory", even if they've checked the box to agree to the code of conduct

This is due to the fact that the branch where that error is generated (line 200 of index.js), the code currently checks to see if the value of req.body.coc is strictly equal to the string '1', but it's actual value is the number 1. Since it's not the same type, strict equality checking fails, but loose equality checking would succeed

A reasonable fix to this would be to loosely check for equality, so it doesn't matter if it's coming in as a string or a number. Alternatively, the code could strictly check for the number 1

The socket.io path does not work with Express app.use()

My use case is mounting multiple copies of Slackin under separate paths. I found that the socket.io URLs are generated correctly on the client side, but the server does not server them.

var express = require('express');
var slackin = require('slackin-extended');

var app = express();
app.use("/path",
      slackin.default({
        org: "team",
        path: "/path",
        token: "token"
    }).app
);

Client requests:

GET /path/socket.io/?....

But receives this error response from Express:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /path/socket.io/</pre>
</body>
</html>

Vertically align main page?

Was the main page vertically aligned in center in the previously released version?

If so, this broke somewhere along the way so I'll need to fix it.

`already_in_team` not reflected in frontend?

So, I was experimenting with the current master branch and I tried to register using my email which I already have an account for.

In the frontend there's nothing shown. In the backend logs I see:

2019-11-23T09:45:53.061928+00:00 app[web.1]: 2019-11-23T09:45:53.061Z slackin:invite Error sending an invite to [email protected]: already_in_team

Is this normal?

Doesn't work on Heroku

Thanks for the fork! I was a contributor to the original slackin repo.

I've had some trouble getting this up and running on Heroku, but I didn't want to send through a pull request because it has to do with the build process, and didn't know what you wanted to do about it.

Basically, this fails to run on Heroku now because there's no dist folder.

Firstly, the package.json needs some kind of build statement that Heroku recognises (post-install or heroku-postbuild so that it can run gulp and generate the dist on dyno building). For example:

diff --git a/package.json b/package.json
index 8c4680f..bc3cc5c 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,8 @@
   "scripts": {
     "test": "mocha && eslint lib/**",
     "build": "gulp",
-    "start": "./bin/slackin"
+    "start": "./bin/slackin",
+    "heroku-postbuild": "gulp"
   },
   "now": {
     "type": "npm",

Secondly, because gulp is listed as a dev dependency, it's not installed in the dyno and the build still fails. The fix for that was to run set the environment variable NPM_CONFIG_PRODUCTION=false

Add a Heroku button

Should get to it after the release.

@XhmikosR does the Heroku deploy work as expected, or should something else be fixed before I add the button?

Latest NPM package wasn't compiled before release

When I download slackin-extended 1.1.10 via npm install -g slackin-extended, and I run the slackin command with my previously-working environment, I get the following error:

internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module './../dist'
Require stack:
- /home/michael/.nvm/versions/node/v12.10.0/lib/node_modules/slackin-extended/bin/slackin
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/home/michael/.nvm/versions/node/v12.10.0/lib/node_modules/slackin-extended/bin/slackin:4:17)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/michael/.nvm/versions/node/v12.10.0/lib/node_modules/slackin-extended/bin/slackin'
  ]
}

The issue seems to stem from the bin/slackin file, where on line 4, it references a folder ./../dist that doesn't seem to exist. Looking at the gulpfile.babel.js, it seems like this is supposed to be generated, but never was. I attempted to compile it myself, but it seems like the versions of gulp/babel that this project uses isn't compatible with node 12.10, so I couldn't. It be great if this project could be compiled, and then the compiled version uploaded as a new version on npm

Error: Too Many Requests

I've been trying to fix our https://github.com/rauchg/slackin instance, and after spending a lot of time fixing simple but hard to spot issues, I keep getting this error. So, then I googled around and found your fork @emedvedev :)

I decided to give it a go and I'm still getting:

2019-10-19T15:50:35.973813+00:00 heroku[web.1]: Starting process with command `bin/slackin --coc "$SLACKIN_COC" --channels "" getbootstrap FOO`
2019-10-19T15:50:38.829158+00:00 app[web.1]: 2019-10-19T15:50:38.827Z slackin:main Theme: light
2019-10-19T15:50:38.837343+00:00 app[web.1]: 2019-10-19T15:50:38.837Z slackin:main Establishing connection with Slack
2019-10-19T15:50:38.869597+00:00 app[web.1]: 2019-10-19T15:50:38.869Z slackin:slack Fetching data from Slack
2019-10-19T15:50:38.892309+00:00 app[web.1]: 2019-10-19T15:50:38.892Z slackin:main Listening on 0.0.0.0:PORT
2019-10-19T15:50:38.953810+00:00 app[web.1]: 2019-10-19T15:50:38.953Z slackin:slack Error: Error: Too Many Requests
2019-10-19T15:50:38.953814+00:00 app[web.1]: at Request.callback (/app/node_modules/superagent/lib/node/index.js:706:15)2019-10-19T15:50:38.953816+00:00 app[web.1]: at parser (/app/node_modules/superagent/lib/node/index.js:916:18)
2019-10-19T15:50:38.953818+00:00 app[web.1]: at IncomingMessage.res.on (/app/node_modules/superagent/lib/node/parsers/json.js:19:7)
2019-10-19T15:50:38.953821+00:00 app[web.1]: at emitNone (events.js:111:20)
2019-10-19T15:50:38.953823+00:00 app[web.1]: at IncomingMessage.emit (events.js:208:7)
2019-10-19T15:50:38.953827+00:00 app[web.1]: at endReadableNT (_stream_readable.js:1064:12)
2019-10-19T15:50:38.953830+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:139:11)
2019-10-19T15:50:38.953832+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:181:9)
2019-10-19T15:50:38.954667+00:00 app[web.1]: 2019-10-19T15:50:38.954Z slackin:slack Attempt failed, will retry
2019-10-19T15:50:39.773455+00:00 heroku[web.1]: State changed from starting to up
2019-10-19T15:51:27.050728+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/badge.svg" host=bootstrap-slack.herokuapp.com request_id=XXX fwd="XXX" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https

Maybe the Slack API calls could be rate limited?

Thanks in advance!

PS. #19 is the other issue I hit while trying your fork.

tag docker inage with sem ver

could you please add tags that represent a version of the application? using the latest tags is not a best practice. thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.