Skip to content

Commit

Permalink
automatically create support account_id (instead of using random admi…
Browse files Browse the repository at this point in the history
…n, which is silly)
  • Loading branch information
williamstein committed Dec 10, 2024
1 parent 8452fb3 commit de87ea8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/packages/server/accounts/create-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ export default async function createAccount({
throw error; // re-throw to bubble up to higher layers if needed
}
}

8 changes: 3 additions & 5 deletions src/packages/server/messages/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import isValidAccount from "@cocalc/server/accounts/is-valid-account";
import getPool from "@cocalc/database/pool";
import { getServerSettings } from "@cocalc/database/settings/server-settings";
import { updateUnreadMessageCount } from "@cocalc/database/postgres/messages";
import getAdmins from "@cocalc/server/accounts/admins";
import basePath from "@cocalc/backend/base-path";
import { join } from "path";
import type { Message } from "@cocalc/util/db-schema/messages";
import { getUser } from "@cocalc/server/purchases/statements/email-statement";
import { getSupportAccountId } from "./support-account";

export async function name(account_id: string) {
const { name: name0, email_address } = await getUser(account_id);
Expand Down Expand Up @@ -49,12 +49,10 @@ export default async function send({
// validate sender -- if not given, assumed internal and tries to send
// from support or an admin
if (!from_id) {
const { support_account_id } = await getServerSettings();
from_id = support_account_id ? support_account_id : (await getAdmins())[0];
from_id = await getSupportAccountId();
}
if (!from_id) {
// if support not configured, just make message be **from the user.**
// this is better than nothing...
// this should be impossible, but just in case.
from_id = to_ids[0];
}
if (!(await isValidAccount(from_id))) {
Expand Down
Loading

0 comments on commit de87ea8

Please sign in to comment.