Skip to content

Commit

Permalink
Merge pull request #371 from jaredwray/upgrading-twilio-to-5.3.3
Browse files Browse the repository at this point in the history
Upgrading twilio to 5.3.3
  • Loading branch information
jaredwray authored Oct 6, 2024
2 parents e477407 + 2dbd696 commit 14ca372
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 54 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "airhorn",
"version": "4.0.0",
"version": "3.1.0",
"description": "Cloud Notification Library",
"type": "module",
"main": "./dist/airhorn.js",
Expand Down Expand Up @@ -48,7 +48,7 @@
"firebase-admin": "^12.4.0",
"gray-matter": "^4.0.3",
"mongodb": "^6.9.0",
"twilio": "^5.3.1"
"twilio": "^5.3.3"
},
"files": [
"dist",
Expand Down
19 changes: 1 addition & 18 deletions src/airhorn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { TemplateService } from './template-service.js';
import { ProviderService } from './provider-service.js';
import { AirhornProviderType } from './provider-type.js';
import { type AirhornSubscription } from './subscription.js';
import { AirhornNotificationStatus, type AirhornNotification } from './notification.js';
import { AirhornQueue, type AirhornQueueProvider } from './queue.js';
import {
AirhornStore, type CreateAirhornNotification, type AirhornStoreProvider, type CreateAirhornSubscription,
AirhornStore, type AirhornStoreProvider, type CreateAirhornSubscription,
} from './store.js';

export type AirhornOptions = {
Expand Down Expand Up @@ -149,22 +148,6 @@ export class Airhorn {

throw new Error('Airhorn store not available');
}

public async publishNotification(notification: CreateAirhornNotification): Promise<void> {
if (this._queue && this._store) {
const updatedNotification = await this._store.createNotification(notification);

await this._queue.publishNotification(updatedNotification);

updatedNotification.status = AirhornNotificationStatus.QUEUED;

await this._store.updateNotification(updatedNotification);

return;
}

throw new Error('Airhorn queue and store needed for notifications');
}
}

export { AirhornProviderType } from './provider-type.js';
Expand Down
34 changes: 0 additions & 34 deletions test/airhorn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,38 +333,4 @@ describe('Airhorn - Notification / Queue', async () => {
const airhorn = new Airhorn({QUEUE_PROVIDER});
expect(airhorn.queue?.provider).toBeDefined();
});
test('Airhorn Queue Publish Notification', async () => {
const QUEUE_PROVIDER = providerMock;
const STORE_PROVIDER = new MongoStoreProvider({uri: 'mongodb://localhost:27017/airhorn'});
const createNotification: CreateAirhornNotification = {
to: 'john@doe.org',
from: 'me@you.com',
subscriptionId: '1234',
externalId: '1234',
providerType: AirhornProviderType.SMTP,
status: AirhornNotificationStatus.QUEUED,
templateName: 'test-template',
templateData: {},
providerName: 'smtp',
};

const airhorn = new Airhorn({QUEUE_PROVIDER, STORE_PROVIDER});
await airhorn.publishNotification(createNotification);
});
test('Airhorn Queue Publish Notification with no Store', async () => {
const QUEUE_PROVIDER = providerMock;
const airhorn = new Airhorn({QUEUE_PROVIDER});
const createNotification: CreateAirhornNotification = {
to: 'john@doe.org',
from: 'me@you.com',
subscriptionId: '1234',
externalId: '1234',
providerType: AirhornProviderType.SMTP,
status: AirhornNotificationStatus.QUEUED,
templateName: 'test-template',
templateData: {},
providerName: 'smtp',
};
await expect(airhorn.publishNotification(createNotification)).rejects.toThrowError(new Error('Airhorn queue and store needed for notifications'));
});
});

0 comments on commit 14ca372

Please sign in to comment.