Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 34b6cbd

Browse files
committed
fix: add update and delete topic for user
1 parent 14e73a9 commit 34b6cbd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

config/default.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ module.exports = {
3535
KAFKA_MESSAGE_ORIGINATOR: process.env.KAFKA_MESSAGE_ORIGINATOR || 'u-bahn-api',
3636

3737
// topics
38-
UBAHN_CREATE_USER_TOPIC: process.env.UBAHN_CREATE_TOPIC || 'user.action.topic.create',
38+
UBAHN_CREATE_USER_TOPIC: process.env.UBAHN_CREATE_USER_TOPIC || 'user.action.topic.create',
39+
UBAHN_UPDATE_USER_TOPIC: process.env.UBAHN_UPDATE_USER_TOPIC || 'user.action.topic.update',
40+
UBAHN_DELETE_USER_TOPIC: process.env.UBAHN_DELETE_USER_TOPIC || 'user.action.topic.delete',
3941
UBAHN_CREATE_TOPIC: process.env.UBAHN_CREATE_TOPIC || 'u-bahn.action.create',
4042
UBAHN_UPDATE_TOPIC: process.env.UBAHN_UPDATE_TOPIC || 'u-bahn.action.update',
4143
UBAHN_DELETE_TOPIC: process.env.UBAHN_DELETE_TOPIC || 'u-bahn.action.delete',

src/modules/user/service.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ async function patch (id, entity, auth, params) {
6868
const result = await sequelize.transaction(async (t) => {
6969
const newEntity = await dbHelper.update(User, id, entity, auth, null, t)
7070
await serviceHelper.patchRecordInEs(resource, newEntity.dataValues, true)
71+
72+
try {
73+
await helper.postEvent(config.UBAHN_UPDATE_USER_TOPIC, newEntity.dataValues)
74+
} catch (err) {
75+
logger.logFullError(err)
76+
}
7177
return newEntity
7278
})
7379

@@ -182,6 +188,11 @@ async function beginCascadeDelete (id, params) {
182188
await serviceHelper.deleteChild(UsersSkill, id, ['userId', 'skillId'], 'UsersSkill', t)
183189
await dbHelper.remove(User, id, null, t)
184190
await serviceHelper.deleteRecordFromEs(id, params, resource, true)
191+
try {
192+
await helper.postEvent(config.UBAHN_DELETE_USER_TOPIC, {id})
193+
} catch (err) {
194+
logger.logFullError(err)
195+
}
185196
})
186197
}
187198

0 commit comments

Comments
 (0)