-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
2 lines (2 loc) · 1.79 KB
/
main.js
1
2
exports = module.exports;
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.slackInviteWebtask=e()}}(function(){return function e(n,r,t){function i(a,f){if(!r[a]){if(!n[a]){var u="function"==typeof require&&require;if(!f&&u)return u(a,!0);if(o)return o(a,!0);var d=new Error("Cannot find module '"+a+"'");throw d.code="MODULE_NOT_FOUND",d}var s=r[a]={exports:{}};n[a][0].call(s.exports,function(e){var r=n[a][1][e];return i(r?r:e)},s,s.exports,e,n,r,t)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a<t.length;a++)i(t[a]);return i}({1:[function(e,n,r){"use strict";function t(e){return function(n,r){return e.writeHead(200,{"Content-Type":"application/json"}),n?void e.end(JSON.stringify({ok:!1,error:n.message})):void e.end("object"==typeof r?JSON.stringify(r):r)}}var i=e("slack-invite");e("url");n.exports=function(e,n,r){var o=t(r);if("POST"!==n.method)return o(new Error("Invalid HTTP METHOD"));var a=e.data.email,f=e.data.SLACK_TEAM,u=e.data.SLACK_TOKEN;if(!f)return o(new Error("Invalid SLACK_TEAM property."));if(!u)return o(new Error("Invalid SLACK_TOKEN property."));if(!a)return o(new Error("Invalid email address"));var d={email:a,team:f,token:u};i(d,function(e){return e&&e.body?void o(null,e.body):void o(null,{success:!0})})}},{"slack-invite":2,url:void 0}],2:[function(e,n,r){var t=e("request"),i=function(e,n){var r=e.email,i=(new Date).getTime(),o=e.team,a=e.channels,f=e.token,u="https://"+o+".slack.com/api/users.admin.invite?t="+i;t.post(u,{form:{email:r,channels:a,token:f,set_active:!0,_attempts:1}},function(e,r,t){n(r)})};n.exports=i},{request:void 0}]},{},[1])(1)});