Skip to content

Commit 0b980c0

Browse files
committed
2 parents 466de35 + f00442a commit 0b980c0

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Forsta Messaging Bot
22
========
33
Secure autonomous message receipt, processing, storage, and/or transmission on the Forsta messaging platform.
44

5-
[License](https://github.com/ForstaLabs/messaging-bot/blob/master/LICENSE)
5+
[License](https://github.com/ForstaLabs/forsta-messaging-bot/blob/master/LICENSE)
66

77

88
About
@@ -12,10 +12,10 @@ It allows for autonomous receipt, processing, storage, and/or transmission of me
1212
data to perform some useful task. Please fork it or one of our several projects based
1313
off of it!
1414

15-
* [Live Chat Bot](https://github.com/ForstaLabs/live-chat-bot)
16-
* [Translation Bot](https://github.com/ForstaLabs/translation-bot)
17-
* [Compliance Monitor](https://github.com/ForstaLabs/compliance-monitor)
18-
* [Message Vault](https://github.com/ForstaLabs/message-vault)
15+
* [Live Chat Bot](https://github.com/ForstaLabs/forsta-live-chat-bot)
16+
* [Translation Bot](https://github.com/ForstaLabs/forsta-translation-bot)
17+
* [Compliance Monitor](https://github.com/ForstaLabs/forsta-compliance-monitor)
18+
* [Message Vault](https://github.com/ForstaLabs/forsta-message-vault)
1919

2020
A Forsta messaging bot can be set up to receive messages sent to a particular user,
2121
**or** (if you are an organization administrator) it can be set up as a special
@@ -61,7 +61,7 @@ Quick Start
6161
These deployment buttons can be used to validate that this messaging bot
6262
will meet your organizations needs with as little setup pain as possible.
6363

64-
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/ForstaLabs/messaging-bot)
64+
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/ForstaLabs/forsta-messaging-bot)
6565

6666
Install Requirements
6767
--------
@@ -75,7 +75,7 @@ Developer Install
7575
If you want to build upon the Forsta Messaging Bot
7676
you can install and run directly from the source code.
7777

78-
git clone https://github.com/ForstaLabs/messaging-bot.git
78+
git clone https://github.com/ForstaLabs/forsta-messaging-bot.git
7979
cd messaging-bot
8080
make run
8181

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Forsta Messaging Bot",
33
"description": "Template for creating bots for the Forsta messaging platform.",
4-
"repository": "https://github.com/ForstaLabs/messaging-bot.git",
4+
"repository": "https://github.com/ForstaLabs/forsta-messaging-bot.git",
55
"logo": "https://raw.githubusercontent.com/ForstaLabs/compliance-monitor/master/images/forsta-logo.svg?sanitize=true",
66
"keywords": ["forsta", "messaging", "bot", "template"],
77
"website": "https://forsta.io",

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"engines": {
66
"node": "8"
77
},
8-
"repository": "ForstaLabs/messaging-bot",
8+
"repository": "ForstaLabs/forsta-messaging-bot",
99
"keywords": [
1010
"forsta",
1111
"e-discovery",
1212
"bot"
1313
],
1414
"license": "GPL-3.0",
1515
"bugs": {
16-
"url": "https://github.com/ForstaLabs/messaging-bot/issues"
16+
"url": "https://github.com/ForstaLabs/forsta-messaging-bot/issues"
1717
},
18-
"homepage": "https://github.com/ForstaLabs/messaging-bot#readme",
18+
"homepage": "https://github.com/ForstaLabs/forsta-messaging-bot#readme",
1919
"scripts": {
2020
"postinstall": "SKIP_PACKAGES=1 make",
2121
"start": "node server"

server/forsta_bot.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ForstaBot {
5555
}
5656

5757
async onMessage(ev) {
58-
//extract the message data from the 'message' event
58+
//extract the message data from the message event
5959
const message = ev.data.message;
6060
const msgEnvelope = JSON.parse(message.body);
6161
let msg;
@@ -76,17 +76,16 @@ class ForstaBot {
7676
return;
7777
}
7878

79-
//log the message data
80-
console.log('msg: ');
79+
console.log('received message: ');
8180
console.log(msg);
8281

8382
// determine the incoming messages' distribution (who the message is sent to)
8483
const dist = await this.resolveTags(msg.distribution.expression);
85-
// retrieve user data from atlas using the sender's user id
84+
// retrieve user data from Atlas using the sender's user id
8685
const senderUser = (await this.getUsers([msg.sender.userId]))[0];
8786
// construct a reply message with their first name
8887
const reply = `Hello, ${senderUser.first_name}!`;
89-
// send the message to the same users on the same thread that it was recieved from
88+
// send the message
9089
this.msgSender.send({
9190
distribution: dist,
9291
threadId: msg.threadId,
@@ -95,9 +94,17 @@ class ForstaBot {
9594
});
9695
}
9796

98-
fqTag(user) { return `@${user.tag.slug}:${user.org.slug}`; }
99-
fqName(user) { return [user.first_name, user.middle_name, user.last_name].map(s => (s || '').trim()).filter(s => !!s).join(' '); }
100-
fqLabel(user) { return `${this.fqTag(user)} (${this.fqName(user)})`; }
97+
fqTag(user) {
98+
return `@${user.tag.slug}:${user.org.slug}`;
99+
}
100+
101+
fqName(user) {
102+
return [user.first_name, user.middle_name, user.last_name].map(s => (s || '').trim()).filter(s => !!s).join(' ');
103+
}
104+
105+
fqLabel(user) {
106+
return `${this.fqTag(user)} (${this.fqName(user)})`;
107+
}
101108

102109
async getSoloAuthThreadId() {
103110
let id = await relay.storage.get('authentication', 'soloThreadId');

server/web/api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class APIHandler {
2525
asyncRoute(fn, requireAuth=true) {
2626
if (process.env.API_AUTH_OVERRIDE === 'insecure') requireAuth = false;
2727

28-
/* Add error handling for async exceptions. Otherwise the server just hangs
28+
/* Adds error handling for async exceptions. Otherwise the server just hangs
2929
* the request or subclasses have to do this by hand for each async routine. */
3030
return (req, res, next) => {
3131
if (requireAuth) {
@@ -94,7 +94,7 @@ class AuthenticationAPIV1 extends APIHandler {
9494
async onStatusGet(req, res, next) {
9595
const registered = await BotAtlasClient.onboardComplete();
9696
res.status(200).json({
97-
status: registered ? 'complete' : (BotAtlasClient.onboardingCreatedUser ? 'authenticate-admin' : 'authenticate-user')
97+
status: registered ? 'complete' : 'authenticate-admin'
9898
});
9999
}
100100

@@ -114,7 +114,7 @@ class AuthenticationAPIV1 extends APIHandler {
114114
const admins = await this.server.bot.getAdministrators();
115115
const isAdmin = admins.filter(a => a.label.split(" ")[0] === "@" + tag);
116116
if (isAdmin.length === 0) {
117-
throw { code: '500', json: { "botAdmin": "You need to authorized by the bot owner to manage this bot." } };
117+
throw { code: '500', json: { "botAdmin": "You need to be a bot adminstrator." } };
118118
}
119119
}
120120
let result = await BotAtlasClient.requestAuthentication(tag);

0 commit comments

Comments
 (0)