summaryrefslogtreecommitdiffstats
path: root/webapp/utils
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-30 10:05:26 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-30 10:05:26 -0400
commit2ab4581d5e658b22c4a957ec57bb3530f92ad66b (patch)
tree4202ebdcbc92905873a15d90a6fb68464bb1629f /webapp/utils
parentfcc80818a8afb6f1e2f9974916f02d5fdeb72ec8 (diff)
parent6a101292c74d33e542e47f8e54fff5a5389bf2ef (diff)
downloadchat-2ab4581d5e658b22c4a957ec57bb3530f92ad66b.tar.gz
chat-2ab4581d5e658b22c4a957ec57bb3530f92ad66b.tar.bz2
chat-2ab4581d5e658b22c4a957ec57bb3530f92ad66b.zip
Merge pull request #2561 from hmhealey/plt1736
PLT-1736 Initial Backstage Work
Diffstat (limited to 'webapp/utils')
-rw-r--r--webapp/utils/async_client.jsx137
-rw-r--r--webapp/utils/constants.jsx8
2 files changed, 145 insertions, 0 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index 6140fd9e0..cc19baa7e 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -1121,3 +1121,140 @@ export function getRecentAndNewUsersAnalytics(teamId) {
}
);
}
+
+export function listIncomingHooks() {
+ if (isCallInProgress('listIncomingHooks')) {
+ return;
+ }
+
+ callTracker.listIncomingHooks = utils.getTimestamp();
+
+ client.listIncomingHooks(
+ (data) => {
+ callTracker.listIncomingHooks = 0;
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_INCOMING_WEBHOOKS,
+ incomingWebhooks: data
+ });
+ },
+ (err) => {
+ callTracker.listIncomingHooks = 0;
+ dispatchError(err, 'getIncomingHooks');
+ }
+ );
+}
+
+export function listOutgoingHooks() {
+ if (isCallInProgress('listOutgoingHooks')) {
+ return;
+ }
+
+ callTracker.listOutgoingHooks = utils.getTimestamp();
+
+ client.listOutgoingHooks(
+ (data) => {
+ callTracker.listOutgoingHooks = 0;
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_OUTGOING_WEBHOOKS,
+ outgoingWebhooks: data
+ });
+ },
+ (err) => {
+ callTracker.listOutgoingHooks = 0;
+ dispatchError(err, 'getOutgoingHooks');
+ }
+ );
+}
+
+export function addIncomingHook(hook, success, error) {
+ client.addIncomingHook(
+ hook,
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_INCOMING_WEBHOOK,
+ incomingWebhook: data
+ });
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ dispatchError(err, 'addIncomingHook');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function addOutgoingHook(hook, success, error) {
+ client.addOutgoingHook(
+ hook,
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_OUTGOING_WEBHOOK,
+ outgoingWebhook: data
+ });
+
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ dispatchError(err, 'addOutgoingHook');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
+export function deleteIncomingHook(id) {
+ client.deleteIncomingHook(
+ {id},
+ () => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.REMOVED_INCOMING_WEBHOOK,
+ id
+ });
+ },
+ (err) => {
+ dispatchError(err, 'deleteIncomingHook');
+ }
+ );
+}
+
+export function deleteOutgoingHook(id) {
+ client.deleteOutgoingHook(
+ {id},
+ () => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.REMOVED_OUTGOING_WEBHOOK,
+ id
+ });
+ },
+ (err) => {
+ dispatchError(err, 'deleteOutgoingHook');
+ }
+ );
+}
+
+export function regenOutgoingHookToken(id) {
+ client.regenOutgoingHookToken(
+ {id},
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.UPDATED_OUTGOING_WEBHOOK,
+ outgoingWebhook: data
+ });
+ },
+ (err) => {
+ dispatchError(err, 'regenOutgoingHookToken');
+ }
+ );
+}
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index 642ff5fe3..f0e8c260e 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -70,6 +70,14 @@ export default {
RECEIVED_FILE_INFO: null,
RECEIVED_ANALYTICS: null,
+ RECEIVED_INCOMING_WEBHOOKS: null,
+ RECEIVED_INCOMING_WEBHOOK: null,
+ REMOVED_INCOMING_WEBHOOK: null,
+ RECEIVED_OUTGOING_WEBHOOKS: null,
+ RECEIVED_OUTGOING_WEBHOOK: null,
+ UPDATED_OUTGOING_WEBHOOK: null,
+ REMOVED_OUTGOING_WEBHOOK: null,
+
RECEIVED_MSG: null,
RECEIVED_MY_TEAM: null,