Closed maxceem closed 3 years ago
@eisbilir one more small change in the kafka message payload format. It appears that Bus API doesn't allow sending Kafka Events with payload: []
which is an array, it only allows the payload to be an object
.
Can we please update supported payload from payload: []
to payload: { notifications: [] }
. I've already updated Event Example here https://gist.github.com/maxceem/bb2ad68d2f8a790f01e3326f9f8015eb
@maxceem https://api.topcoder-dev.com/v5/users/{uuid}?enrich=true
is not returning email address. I tried with m2mToken, m2mTokenForUbahn, admin token and searched several uuids including yours.
I made all necessary updates, but it won't work when we are not able to get emails by UUID
When the only provided field is UUID, should I get the handle by UUID after that, get email by handle?
PR https://github.com/topcoder-platform/tc-notifications/pull/216 I tried the workaround UUID => userId => email
@eisbilir your solution UUID => userId => email
works great, and I don't see a better way.
During testing of the PR it failed, but it only fails for some users who most likely don't have V3 user profile because of data inconsistency on DEV.
Thanks!
This was deployed to DEV and tested locally, closing.
Payment processed by https://www.topcoder.com/challenges/7e694e52-5d85-4c63-845b-b561c7d661ec
Background
At the moment to send email or web notification we require to
userId
and/oremail
address as per the Kafka Message payload format https://gist.github.com/maxceem/bb2ad68d2f8a790f01e3326f9f8015eb#file-notification-action-create-js-L9-L48Though sometimes service which sends notification doesn't know
userId
/email
and have just ahandle
for example. We don't want to ask each service to implement functionality to retrieveuserId
/email
. Instead of this, we would allow passing only of the user identifier likeuserId
,userUUID
,email
orhandle
and tc-notificatoin would have to get any details about the user necessary for sending notifications by itself.Task
For
email
therecipients
array should allow passing the next object:email
so we have to getemail
if it's not passed byuserId
oruserUUID
orhandle
. If we could not getemail
- log error as we cannot send notification in such a case.userId
which is needed to check user settings. So we have to usehandle
,email
oruserUUID
to getuserId
. If user is not found, then still send notification to theemail
, this would be needed in case if user is not registered yet. But if there is some other error while gettinguserId
(not NOT FOUND), then don't send email and log error as we failed to getuserId
.cc
of the email. Thoug as we don't need to check setting for the user, thenuserId
forcc
is not need to retrieve.For
web
notification:userId
field withrecipients
wich would also be an array. And we would should send thisweb
notification toeach
member in therecipients
array.recipients
array should allow the same objects as for email:web
notification we needuserId
, so we have to get it byuserUUID
oremail
ofhandle
depend on what is provided.userId
for any reason - log error as we cannot create web notification withoutuserId
.API Endpoints
We have 2 kind of user ids in Topcoder which are provided by different services, though we keeping user in sync between them.
userId
is a numeric user id like13123123
userUUID
is string UUID user id like1323423421-asdfas-123asdf-123
For example, TC-Notifications services use only
userId
, while TaaS API always usesuserUUID
.Get
userId
userId
byuserUUID
- https://github.com/topcoder-platform/taas-apis/blob/feature/notifications-scheduler/src/common/helper.js#L1065-L1095 (enrich
can befalse
)userId
byemail
- https://github.com/topcoder-platform/tc-project-service/blob/feature/new-milestone-concept/src/util.js#L909-L947userId
byhandle
- https://github.com/topcoder-platform/tc-project-service/blob/feature/new-milestone-concept/src/util.js#L584-L608Get
email
email
byuserUUID
- https://github.com/topcoder-platform/taas-apis/blob/feature/notifications-scheduler/src/common/helper.js#L1065-L1095 (enrich
must betrue
to return emails )email
byuserId
- https://github.com/topcoder-platform/tc-project-service/blob/feature/new-milestone-concept/src/util.js#L559-L579email
byhandle
- https://github.com/topcoder-platform/tc-project-service/blob/feature/new-milestone-concept/src/util.js#L584-L608API Notes
recipients
array. (theoretically, we call it only once per Kafka message for all items in the payload, but it might be too many users at once, so calling it per notification object inside the payload array should be fine).userUUID
we would need to create a separate M2M token specially for u-bahn like in TaaS API https://github.com/topcoder-platform/taas-apis/blob/feature/notifications-scheduler/src/common/helper.js#L889-L894