fix: add accountSid and twilioPhoneNumber to notification repositories

Updated both MongoDB and TimescaleDB repositories to map the new
Twilio-specific fields (accountSid, twilioPhoneNumber) in create,
update, and toEntity methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
egeoztassandClaude Opus 4.6 committed 2026-04-17 23:14:16 +03:00
1 parent d5d6797f91
commit c57614e8df
2 files changed
+13 -3

No files matched your search

@@ -32,6 +32,8 @@ class MongoNotificationsRepository implements INotificationsRepository {
homeserverUrl: doc.homeserverUrl ?? undefined,
roomId: doc.roomId ?? undefined,
accessToken: doc.accessToken ?? undefined,
accountSid: doc.accountSid ?? undefined,
twilioPhoneNumber: doc.twilioPhoneNumber ?? undefined,
createdAt: toDateString(doc.createdAt),
updatedAt: toDateString(doc.updatedAt),
};
@@ -14,20 +14,22 @@ interface NotificationRow {
homeserver_url: string | null;
room_id: string | null;
access_token: string | null;
account_sid: string | null;
twilio_phone_number: string | null;
created_at: Date;
updated_at: Date;
}
const COLUMNS = `id, user_id, team_id, type, notification_name, address, phone,
homeserver_url, room_id, access_token, created_at, updated_at`;
homeserver_url, room_id, access_token, account_sid, twilio_phone_number, created_at, updated_at`;
export class TimescaleNotificationsRepository implements INotificationsRepository {
constructor(private pool: Pool) {}
create = async (data: Partial<Notification>): Promise<Notification> => {
const result = await this.pool.query<NotificationRow>(
`INSERT INTO notifications (user_id, team_id, type, notification_name, address, phone, homeserver_url, room_id, access_token)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
`INSERT INTO notifications (user_id, team_id, type, notification_name, address, phone, homeserver_url, room_id, access_token, account_sid, twilio_phone_number)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
RETURNING ${COLUMNS}`,
[
data.userId,
@@ -39,6 +41,8 @@ export class TimescaleNotificationsRepository implements INotificationsRepositor
data.homeserverUrl ?? null,
data.roomId ?? null,
data.accessToken ?? null,
data.accountSid ?? null,
data.twilioPhoneNumber ?? null,
]
);
const row = result.rows[0];
@@ -83,6 +87,8 @@ export class TimescaleNotificationsRepository implements INotificationsRepositor
["homeserverUrl", "homeserver_url"],
["roomId", "room_id"],
["accessToken", "access_token"],
["accountSid", "account_sid"],
["twilioPhoneNumber", "twilio_phone_number"],
];
for (const [key, column] of fieldMap) {
@@ -134,6 +140,8 @@ export class TimescaleNotificationsRepository implements INotificationsRepositor
homeserverUrl: row.homeserver_url ?? undefined,
roomId: row.room_id ?? undefined,
accessToken: row.access_token ?? undefined,
accountSid: row.account_sid ?? undefined,
twilioPhoneNumber: row.twilio_phone_number ?? undefined,
createdAt: row.created_at.toISOString(),
updatedAt: row.updated_at.toISOString(),
});