Compare commits

..

No commits in common. "4da9429e6ef1f3ec1c8a25ba1c597348e724751a" and "ac30269c81f29e0e02d081a3133ba9d553008544" have entirely different histories.

3 changed files with 20 additions and 42 deletions

View File

@ -1,17 +0,0 @@
import { Knex } from "knex";
export async function up(knex: Knex) {
return knex.transaction((trx) =>
trx.schema.alterTable("voicemails", (table) => {
table.string("fromName", 64).alter();
})
);
}
export async function down(knex: Knex) {
return knex.transaction((trx) =>
trx.schema.alterTable("voicemails", (table) => {
table.string("fromName", 64).notNullable().alter();
})
);
}

View File

@ -68,24 +68,20 @@ async function initRingCentralSDK() {
clientId: process.env.RC_APP_KEY, clientId: process.env.RC_APP_KEY,
clientSecret: process.env.RC_APP_SECRET, clientSecret: process.env.RC_APP_SECRET,
}); });
const login = () =>
sdk.login({
username: process.env.RC_LOGIN_USERNAME,
extension: process.env.RC_LOGIN_EXT,
password: process.env.RC_LOGIN_PASSWORD,
});
const platform = sdk.platform(); const platform = sdk.platform();
platform.on(platform.events.refreshError, async (err) => { platform.on(platform.events.refreshError, (err) => {
console.error("Refresh token error:", err); console.error("Refresh error", err);
await login(); });
console.log("RingCentral re-authentication successful."); const client = sdk.client();
client.on(client.events.beforeRequest, (request) => {
console.log(request.url);
});
await sdk.login({
username: process.env.RC_LOGIN_USERNAME,
extension: process.env.RC_LOGIN_EXT,
password: process.env.RC_LOGIN_PASSWORD,
}); });
await login();
console.log("Authenticated to RingCentral."); console.log("Authenticated to RingCentral.");
return sdk; return sdk;
} }

View File

@ -5,21 +5,19 @@ import { DateTime } from "luxon";
import type { Contact } from "./types"; import type { Contact } from "./types";
import type { StoredVoicemail, StoredRecording } from "knex/types/tables"; import type { StoredVoicemail, StoredRecording } from "knex/types/tables";
function fromName(vm: StoredVoicemail, contact?: Contact) { export function getTicketSubject(
return contact?.name ?? vm.fromName ?? "unknown"; voicemail: StoredVoicemail,
} contact?: Contact
) {
export function getTicketSubject(vm: StoredVoicemail, contact?: Contact) { return `New Voicemail from ${getNationalNumber(voicemail.fromNumber)} (${
const name = fromName(vm, contact); contact ? contact.name : voicemail.fromName
return `New Voicemail from ${getNationalNumber(vm.fromNumber)} (${name})`; })`;
} }
export function getTicketBody( export function getTicketBody(
vm: StoredVoicemail & StoredRecording, vm: StoredVoicemail & StoredRecording,
contact?: Contact contact?: Contact
) { ) {
const name = fromName(vm, contact);
return ReactDOMServer.renderToStaticMarkup( return ReactDOMServer.renderToStaticMarkup(
<div> <div>
<div> <div>
@ -27,7 +25,8 @@ export function getTicketBody(
{DateTime.fromISO(vm.received).toLocaleString(DateTime.DATETIME_MED)} {DateTime.fromISO(vm.received).toLocaleString(DateTime.DATETIME_MED)}
</div> </div>
<div> <div>
<b>From:</b> {getNationalNumber(vm.fromNumber)} ({name}) <b>From:</b> {getNationalNumber(vm.fromNumber)} (
{contact?.name ?? vm.fromName})
</div> </div>
<div> <div>
<b>To:</b> {getNationalNumber(vm.toNumber)}x{vm.extensionNumber} ( <b>To:</b> {getNationalNumber(vm.toNumber)}x{vm.extensionNumber} (