@lightupai/polaris 0.0.41 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +3 -0
- package/docker-compose.prod.yml +1 -0
- package/package.json +1 -1
- package/src/web/app.ts +40 -0
package/.env.example
CHANGED
package/docker-compose.prod.yml
CHANGED
|
@@ -45,6 +45,7 @@ services:
|
|
|
45
45
|
SLACK_CLIENT_ID: ${SLACK_CLIENT_ID}
|
|
46
46
|
SLACK_CLIENT_SECRET: ${SLACK_CLIENT_SECRET}
|
|
47
47
|
SLACK_REDIRECT_URI: https://app.withpolaris.ai/slack/callback
|
|
48
|
+
SIGNUP_SLACK_BOT_TOKEN: ${SIGNUP_SLACK_BOT_TOKEN:-}
|
|
48
49
|
depends_on:
|
|
49
50
|
postgres:
|
|
50
51
|
condition: service_healthy
|
package/package.json
CHANGED
package/src/web/app.ts
CHANGED
|
@@ -30,6 +30,28 @@ import {
|
|
|
30
30
|
mockDevices,
|
|
31
31
|
} from "./fixtures";
|
|
32
32
|
|
|
33
|
+
// --- Signup notifications ---
|
|
34
|
+
|
|
35
|
+
const SIGNUP_CHANNEL = "#alerts-mql-stream";
|
|
36
|
+
|
|
37
|
+
function notifySignup(opts: { name: string; email: string; domain: string; orgName: string; isNewOrg: boolean }): void {
|
|
38
|
+
const botToken = process.env.SIGNUP_SLACK_BOT_TOKEN;
|
|
39
|
+
if (!botToken) return;
|
|
40
|
+
|
|
41
|
+
const emoji = opts.isNewOrg ? ":tada:" : ":wave:";
|
|
42
|
+
const action = opts.isNewOrg ? "signed up (new org)" : "joined";
|
|
43
|
+
const text = `${emoji} *${opts.name}* (${opts.email}) ${action} — ${opts.orgName} (${opts.domain})`;
|
|
44
|
+
|
|
45
|
+
fetch("https://slack.com/api/chat.postMessage", {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: {
|
|
48
|
+
Authorization: `Bearer ${botToken}`,
|
|
49
|
+
"Content-Type": "application/json",
|
|
50
|
+
},
|
|
51
|
+
body: JSON.stringify({ channel: SIGNUP_CHANNEL, text }),
|
|
52
|
+
}).catch(() => {});
|
|
53
|
+
}
|
|
54
|
+
|
|
33
55
|
// --- Google OAuth ---
|
|
34
56
|
|
|
35
57
|
function getGoogle(): Google {
|
|
@@ -129,6 +151,20 @@ export function createApp(sql: Sql) {
|
|
|
129
151
|
const userId = crypto.randomUUID();
|
|
130
152
|
const participantId = `user:${name.toLowerCase().replace(/\s+/g, ".")}`;
|
|
131
153
|
await createUser(sql, userId, email, name, existingOrg.id, participantId);
|
|
154
|
+
|
|
155
|
+
// Notify org's Slack system channel
|
|
156
|
+
postSystemEvent({
|
|
157
|
+
sql,
|
|
158
|
+
orgId: existingOrg.id,
|
|
159
|
+
sender: participantId,
|
|
160
|
+
text: `:wave: *${name}* (${email}) joined the team`,
|
|
161
|
+
botToken: existingOrg.slack_bot_token ?? undefined,
|
|
162
|
+
channelId: existingOrg.slack_system_channel_id ?? undefined,
|
|
163
|
+
}).catch(() => {});
|
|
164
|
+
|
|
165
|
+
// Notify internal team
|
|
166
|
+
notifySignup({ name, email, domain, orgName: existingOrg.name, isNewOrg: false });
|
|
167
|
+
|
|
132
168
|
const token = await createToken({ sub: userId, email, name, org_id: existingOrg.id, participant_id: participantId });
|
|
133
169
|
return authRedirect(c, state, token);
|
|
134
170
|
}
|
|
@@ -144,6 +180,10 @@ export function createApp(sql: Sql) {
|
|
|
144
180
|
const userId = crypto.randomUUID();
|
|
145
181
|
const participantId = `user:${name.toLowerCase().replace(/\s+/g, ".")}`;
|
|
146
182
|
await createUser(sql, userId, email, name, orgId, participantId);
|
|
183
|
+
|
|
184
|
+
// Notify internal team
|
|
185
|
+
notifySignup({ name, email, domain, orgName, isNewOrg: true });
|
|
186
|
+
|
|
147
187
|
const token = await createToken({ sub: userId, email, name, org_id: orgId, participant_id: participantId });
|
|
148
188
|
return authRedirect(c, state, token);
|
|
149
189
|
});
|