Skip to content

Commit

Permalink
feat(notice): update grand badge link
Browse files Browse the repository at this point in the history
  • Loading branch information
gary02 committed Jul 23, 2024
1 parent 6ce9c18 commit 2765545
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion handlers/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { SQSEvent } from 'aws-lambda'
import { getKnexClient } from '../lib/utils/db.js'
import { NotificationService } from '../lib/notification/index.js'

// envs
// MATTERS_DOMAIN
// MATTERS_PG_CONNECTION_STRING
// MATTERS_PG_RO_CONNECTION_STRING

const knex = getKnexClient(process.env.MATTERS_PG_CONNECTION_STRING || '')
const knexRO = getKnexClient(process.env.MATTERS_PG_RO_CONNECTION_STRING || '')

Expand All @@ -14,7 +19,7 @@ export const handler = async (event: SQSEvent) => {
notificationService.trigger(JSON.parse(body))
)
)
// print failed reseaon
// print failed reason
results.map((res) => {
if (res.status === 'rejected') {
console.error(res.reason)
Expand Down
10 changes: 8 additions & 2 deletions lib/notification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,15 +729,21 @@ export class NotificationService {
}),
data: params.data,
}
case OFFICIAL_NOTICE_EXTEND_TYPE.badge_grand_slam_awarded:
case OFFICIAL_NOTICE_EXTEND_TYPE.badge_grand_slam_awarded: {
const recipient = await this.knexRO('user')
.select('user_name')
.where({ id: params.recipientId })
.first()
const domain = process.env.MATTERS_DOMAIN ?? 'matters.town'
return {
type: NOTICE_TYPE.official_announcement,
recipientId: params.recipientId,
message: trans.badge_grand_slam_awarded(language, {}),
data: {
link: 'https://matters.town/placeholder/',
link: `https://${domain}/@${recipient.userName}?dialog=grand-badge&step=congrats`,
},
}
}
default:
// for exhaustively handle enum values,
// see https://medium.com/typescript-tidbits/exhaustively-handle-enum-values-in-switch-case-at-compile-time-abf6cf1a42b7
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lambda-handlers-image",
"version": "0.10.1",
"version": "0.10.2",
"private": true,
"type": "module",
"scripts": {
Expand Down

0 comments on commit 2765545

Please sign in to comment.