Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

feat(client, db): event url #423

Merged
merged 6 commits into from
Nov 1, 2020
Merged

feat(client, db): event url #423

merged 6 commits into from
Nov 1, 2020

Conversation

gh-23378
Copy link
Contributor

  • I have read Chapter's contributing guidelines.
  • My pull request has a descriptive title (not a vague title like Update README.md).
  • My pull request targets the master branch of Chapter.

Closes #381

Added URL field to event model, created migration for new column to be added to event table, updated seeders to generate fake URLs, updated UI to allow read and update on URL.

While working on this I noticed that the form to edit events is creating new events.

@gh-23378 gh-23378 changed the title Feat/event url feat(client, db): event url Oct 25, 2020
Copy link
Contributor

@timmyichen timmyichen left a comment

Choose a reason for hiding this comment

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

Do any tests need updating? Do we even have tests for this? 🤔

@gh-23378
Copy link
Contributor Author

The only tests I saw were for the mailer

@allella
Copy link
Contributor

allella commented Oct 26, 2020

I'm no good on the technical end, but this does appear to add an event.url as we discussed in #378 and which became #381 so I'm good with it.

@KatieN it sounded like @timmyichen and @Ryuno-Ki were suggesting adding logic to validate the value passed in is actually a valid URL. Could that be added to this PR?

@gh-23378
Copy link
Contributor Author

Validation is in there :)

server/controllers/Events/resolver.ts Outdated Show resolved Hide resolved
server/controllers/Events/resolver.ts Outdated Show resolved Hide resolved
@gh-23378 gh-23378 mentioned this pull request Oct 26, 2020
3 tasks
@allella allella self-requested a review October 29, 2020 21:13
Copy link
Contributor

@allella allella left a comment

Choose a reason for hiding this comment

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

I'm good with this from the business logic. If @timmyichen and @Ryuno-Ki are good then holler and one of us can merge it.

@allella
Copy link
Contributor

allella commented Oct 30, 2020

@Ryuno-Ki if you give the formal approval, then we'll merge this in.

@Ryuno-Ki
Copy link
Contributor

Sorry, I was busy the last days. Lemme take a look!

Copy link
Contributor

@Ryuno-Ki Ryuno-Ki left a comment

Choose a reason for hiding this comment

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

I'm worried about the lack of validation on URL input.
For example, this could lead to a persistent XSS via javascript: protocol.
But this could be also adressed in a followup-PR.

So I'm approving with comments.

@@ -302,7 +305,7 @@ export type EventsQuery = { __typename?: 'Query' } & {
events: Array<
{ __typename?: 'Event' } & Pick<
Event,
'id' | 'name' | 'canceled' | 'description' | 'capacity'
'id' | 'name' | 'canceled' | 'description' | 'url' | 'capacity'
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to have these ordered alphabetically?
(The OCD in me. Would not block a merge IMHO).

@@ -320,6 +323,7 @@ export type EventQuery = { __typename?: 'Query' } & {
| 'id'
| 'name'
| 'description'
| 'url'
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to sort these alphabetically?
(Not blocking a merge IMHO).

@@ -37,6 +37,7 @@ const EventItem: React.FC<IEventItemProps> = ({ loading, event }) => {
<Typography variant="body2" color="textSecondary" component="p">
{event.description}
</Typography>
{event.url && <a href={event.url}>{event.url}</a>}
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps worth to wrap in a p, too?

@@ -48,6 +48,7 @@ export const EventPage: NextPage = () => {
<Typography variant="body2" color="textSecondary" component="p">
{data.event.description}
</Typography>
<a href={data.event.url}>{data.event.url}</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps worth to wrap in a <p>, too?

@gh-23378
Copy link
Contributor Author

@Ryuno-Ki agreed on sanitization being important, @timmyichen and I were going back and forth on how to handle this here since the suggested new URL() wasn't doing what we wanted (new URL("javascript:alert('foo')") would pass, for example). FYI URL validation has also been removed from my other PR with the assumption it would be handled in a later issue

@Ryuno-Ki
Copy link
Contributor

Could we at least have an issue for that?
It would be handy if it would link to those discussions here and your other PR.

@allella
Copy link
Contributor

allella commented Nov 1, 2020

We can continue the conversation on URL validation on #430. If there are no final points, then we'll merge #423 and #424.

@allella
Copy link
Contributor

allella commented Nov 1, 2020

@Ryuno-Ki agreed to proceed on Discord

Looked at #423. Fine with me, but make sure to fill some issues / followup-PRs, @allella
Yes, sanitizing is important. Input validation as well. Those are the two cornerstones of web security.

@allella allella merged commit ff65c21 into freeCodeCamp:master Nov 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add event URL for each event
4 participants