Commit Graph

21 Commits

Author SHA1 Message Date
Daniel Lockyer
6c7b230efe Fixed handling requests with mismatching version and missing key
fix https://linear.app/tryghost/issue/SLO-88/typeerror-cannot-read-properties-of-null-reading-relations

- in the event that we make it through the version mismatch code, but
  without a key, which is possible if you send a request like POST
  /ghost/api/v2/content/posts/`, then the version mismatch code will try
  and look up the API key attached to a null key, which won't work
- we should handle this case and soft return, to avoid trying to read
  `.relations` from `null`
- I'm not entirely convinced by how this code works in general, it seems
  quite confusing to reason about, but this commit should solve the HTTP
  500 we've been seeing from this
- perhaps in the future we can return earlier in the flow if we receive
  a `null` key
2024-05-02 13:03:26 +02:00
Fabien "egg" O'Carroll
104f84f252 Added eslint rule for file naming convention
As discussed with the product team we want to enforce kebab-case file names for
all files, with the exception of files which export a single class, in which
case they should be PascalCase and reflect the class which they export.

This will help find classes faster, and should push better naming for them too.

Some files and packages have been excluded from this linting, specifically when
a library or framework depends on the naming of a file for the functionality
e.g. Ember, knex-migrator, adapter-manager
2023-05-09 12:34:34 -04:00
Naz
478eb6ead6
Limited integrations triggering version mismatch emails
refs https://github.com/TryGhost/Toolbox/issues/500
refs https://ghost.notion.site/Data-Types-e5dc54dd0078443f9afd6b2abda443c4

- There current notification logic for incompatible integrations did not take into account the source of the trigger, which might have been causing emails to instance owners that did not ever set up custom integration - so they had nothing to fix.
- The "internal" and "core" integrations are maintained/controlled by the Ghost team, so there should never be a notification going out to the instance owner about possible incompatibility in the code they do not control.
- Along with changed updated the unit test threshold in the packages that were touched to 100%. As that's the standard for all new packages.
2023-01-30 17:57:14 +08:00
Peter Schulz
9a7467f343 Removed copy error in generic message 2022-05-24 08:22:00 -07:00
Naz
d9d84c25ec Changes email notification template copy
refs https://github.com/TryGhost/Toolbox/issues/292

- Copy change was based on feedback pointed out by Peter.
2022-05-11 10:48:32 +08:00
Naz
32d888d3cc Fixed email copy based on feedback
refs https://github.com/TryGhost/Toolbox/issues/292

- The email copy had a few bits that were off after the review. This fixes them.
2022-05-11 10:37:18 +08:00
Naz
9d875e7d45 Fixed use of integration name in the email subject
refs https://github.com/TryGhost/Toolbox/issues/292

- The integraton name should be used instead of the user agent!
2022-05-11 10:08:32 +08:00
Naz
8cc9fc4353 Substituted UserAgent with Integration Name in emails
refs https://github.com/TryGhost/Toolbox/issues/292

- Providing user-defined Integration name instead of API client's UserAgent gives a lot more control to instance administrators identifying which integration is being used incorrectly.
- It's best practice to create an Integration with a set of API keys per API client - which should be enough to identify an outdated one.
2022-05-10 17:33:15 +08:00
Naz
35031b8f2e Refactored api version compatibility service API
refs https://github.com/TryGhost/Toolbox/issues/292

- The service used to take in a whole bunch of functions as parameters and did expect the client to know about the "version-notifications-data-service" which is not necessary and make the constructor API a notch complicated
- Putting in the data service initialization internally allows for the client to pass in less parameters and know less abou the internal working of the service - way easier to use!
2022-05-09 18:14:41 +08:00
Naz
521ddc001c Added request url parameter to notification emails
refs https://github.com/TryGhost/Toolbox/issues/292

- Generic version mismatch notification emails contain request url which had to be parameterized to function properly.
2022-05-05 14:51:47 +08:00
Naz
b2f585e0d0 Added Zapier-specific email templates
refs https://github.com/TryGhost/Toolbox/issues/292

- When the handler recognizes a Zapier client it should send an email using Zapier-specific template with instructions more suitable for Zap failure
2022-05-05 12:43:55 +08:00
Naz
1a0a4272f3 Extracted template to be a separate variable
refs https://github.com/TryGhost/Toolbox/issues/292

- Nice to track the change history
2022-05-05 12:32:52 +08:00
Naz
30f8b0a446 Added support for html templates in version emails
refs https://github.com/TryGhost/Toolbox/issues/292

- The html/text emails is a desired system that's used in Ghost core and should be reused with version mismatch notification emails too.
- Currently there's only one template defined "generic-mismatch" and the original file for it can be found under /templates/generic-mismatch.html
- If we need to distinguish user agents we can addd more templates to the `/templates/` folder
2022-05-05 12:17:30 +08:00
Naz
06c733bb0b Added explicit "text" parameter in sendEmail call
refs https://github.com/TryGhost/Toolbox/issues/292

- This is groundwork before adding separate html/text generation. Should make future additions more readable
2022-05-05 12:17:30 +08:00
Naz
ff4bdb5ff8 Made integration naming less technical
refs https://github.com/TryGhost/Toolbox/issues/292

- The audience of the notification emails for version missmatch could be less technical - site owneres are usually creators not programmers. Not using complex technical details in the email subject/body should make the incompatibility more approachable to deal with.
2022-05-04 11:05:48 +08:00
Naz
f21a403538 Fixed incompatibility subject line
refs https://github.com/TryGhost/Toolbox/issues/292

- This is the subject line with the latest proposed copy
2022-04-21 16:01:56 +08:00
Naz
8414e927f9 Added handling of multiple owners to notify
refs https://github.com/TryGhost/Toolbox/issues/292

- There can be multiple users in the Ghost instance that should be notifiied about version mismatch. Following the logic of the security notifications these are users with 'Owner' and 'Administrator' roles. To have the most up to date list of the emails to notify the emails fetching was made dinamic and is now passed in as a 'fetchEmailsToNotify' function.
- Also fixed the subject of the email to match the final copy
2022-04-21 15:57:43 +08:00
Naz
a7fccf1bf8 Fixed email sending
refs https://github.com/TryGhost/Toolbox/issues/292

- The standard sendEmail function used in Ghost accepts three non-optional parameters: to, subject, and html. Have extended the usage with these three required fields
2022-04-21 15:57:43 +08:00
Naz
188707c5bb Added previously handled checking logic
refs https://github.com/TryGhost/Toolbox/issues/292

- Added additional logic needed to check if the passed in `Accept-Version` header has been handled
2022-04-21 15:57:43 +08:00
Naz
a8333f22d8 Added bare bones functionality sending an email
refs https://github.com/TryGhost/Toolbox/issues/292

- Super happy path scenario which handles sending information with some basic incompatibility information
- It's meant to be built up upon! More to follow :)
2022-04-21 15:57:43 +08:00
Naz
178856cf82 Bootstrapped api version compatibility package
refs https://github.com/TryGhost/Toolbox/issues/292

- Fresh package out of Super Slimer
2022-04-21 15:57:43 +08:00