Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix store invite #113

Merged
merged 9 commits into from
Jul 17, 2024
Merged

Fix store invite #113

merged 9 commits into from
Jul 17, 2024

Conversation

h1ppox99
Copy link
Collaborator

No description provided.

@h1ppox99 h1ppox99 requested a review from guimard July 12, 2024 11:09
@h1ppox99 h1ppox99 marked this pull request as draft July 12, 2024 11:09
@@ -55,18 +55,34 @@
)
}

// TODO : modify this if necessary

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
@@ -77,6 +77,9 @@
})
return
}

// TODO : hook for any pending invite and call the onbind api : https://spec.matrix.org/v1.11/client-server-api/#room-aliases

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
})
.catch((err) => {
/* istanbul ignore next */
this.logger.error('Failed to insert token', err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "reject": a promise must always call resolve or reject

}
})
.catch((e) => {
reject(e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add logger.error ?

.set('Authorization', `Bearer ${validToken}`)
.set('Accept', 'application/json')
.send({
address: '+33612345678',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"address" looks a bad name here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name has to be the same for the different media. But the spec only supports mail so this is named address for the moment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at others API, phone is used to designate phone when type is "pĥone"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the most common use is "country" (The two-letter uppercase ISO-3166-1 alpha-2 country code that the number in phone_number should be parsed as if it were dialled from) + "phone_number"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is an encoding convention for phone in Matrix spec: international number without + or spaces

.replace(/__room_name__/g, room_name)
.replace(/__room_avatar__/g, room_avatar)
.replace(/__room_type__/g, room_type)
.replace(/__link__/g, inviteLink('matrix.to', sender_user_id, room_alias))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matrix.to must be a config parameter, not a fixed string

@@ -134,6 +173,7 @@ const StoreInvit = <T extends string = never>(
return (req, res) => {
idServer.authenticate(req, res, (_data, _id) => {
jsonContent(req, res, idServer.logger, (obj) => {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
validateParameters(res, schema, obj, idServer.logger, async (obj) => {
const _address = (obj as storeInvitationArgs).address
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't use the same fields name address for a phone number

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a different endpoint for phone maybe ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also be a different schema. If type is email, address is required, else phone is required

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then the token I store will have two fields (phone and address) and one of them will be empty. Is it ok ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we talking about database schema or API field names ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am now talking about how I store the invitation in the db, should I do the same thing as for the API field names, ie add a new column phone which will sometimes be empty, or keep one column for addresses which will store email as well as phone numbers ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was talking about API fieldnames. For DB, do what is useful for you

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the synapses db, the convention is to use a medium and an address, address being either an email address or a phone number. I will stick to this usage

@guimard
Copy link
Member

guimard commented Jul 12, 2024

Please add a link to your MR in related issues when exist (#62) here

})
break
case 'msisdn':
// TODO implement smsSender

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
@guimard
Copy link
Member

guimard commented Jul 16, 2024

Remember to drop "draft" mode for review

@h1ppox99 h1ppox99 marked this pull request as ready for review July 17, 2024 05:20
@h1ppox99 h1ppox99 merged commit 40128c0 into full-id-service Jul 17, 2024
8 checks passed
@h1ppox99 h1ppox99 deleted the fix-store-invite branch July 17, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants