Commit Graph

307 Commits

Author SHA1 Message Date
Fabien 'egg' O'Carroll
34eae1f284
Promoted Member Attribution to a private beta (#15316)
We promote from alpha -> beta so that we don't require the
enableDeveloperExperiments flag, the toggle in the UI is behind the
flag still, so it will only be visible to developers or people using
alpha features.
2022-08-25 15:41:43 -04:00
Simon Backx
67163209e1
Enabled member attribution flag in all tests (#15317)
closes https://github.com/TryGhost/Team/issues/1852

Updates all tests to run with memberAttribution flag enabled
2022-08-25 15:25:01 -04:00
Rishabh
e6246b191e Updated options format in email alert method to prevent filter override
refs https://github.com/TryGhost/Team/issues/1826

- doesn't allow `filter` to be overridden by passed in options
2022-08-25 20:15:54 +05:30
Rishabh
216eeb9d71 Added paid subscription start email alert
refs TryGhost/Team#1826

- triggers paid subscription start email via staff service
2022-08-25 19:53:02 +05:30
Rishabh
aeadf8a5e1 Added email alert trigger for free member signup
refs TryGhost/Team#1826

- fires email alert on free member creation after they finish signing up via checkout link
2022-08-25 19:53:02 +05:30
Simon Backx
a8239bfa97
Added ENUM validation for member/subscription created events (#15312)
closes https://github.com/TryGhost/Team/issues/1842

- members_created_events: source + attribution_type
- members_subscription_created_events: attribution_type
- members_subscribe_events: source
2022-08-25 15:39:37 +02:00
Simon Backx
232882daa2 Mapped '/' attribution url to homepage
fixes https://github.com/TryGhost/Team/issues/1846

- Shows homepage instead of / for attribution values
2022-08-25 14:51:38 +02:00
Rishabh
281d52610f Added staff service to manage email alert notifications
refs TryGhost/Team#1826

- adds new service package that manages all the email alert notifications for free members and paid subscriptions
- includes email templates for free member signup and paid subscription start/cancel
- initializes staff service before members to allow managing email alert notifications
- passes staff service to members api for triggering alerts
2022-08-25 18:01:52 +05:30
Rishabh
effd5af615 Handled fetching staff users for email alerts
refs TryGhost/Team#1826

- adds a method on user model which fetches all eligible users for a type of email alert
- restricts users to active `Owner` and `Administrators` with setting turned on
2022-08-25 18:01:52 +05:30
Naz
6e76fcc36a Parameterized api sourced verification threshold
refs https://github.com/TryGhost/Toolbox/issues/387

- The limit values should be as configurable as possible to adjust verification thresholds dinamically per-usecase. This solves a problem of doing a separate version release when we need to adjust the verification thresholds.
- Before this "importThreshold" was the same concept as "apiThreshold", which makes it hard&confusing to reason about and hard to parameterize each specific case.
2022-08-25 17:07:10 +08:00
Rishabh
7182ee0e85 Added feature flag for email alerts
refs https://github.com/TryGhost/Team/issues/1826

- adds alpha flag for setting up email alerts for staff users
2022-08-25 13:03:13 +05:30
Naz
7e3b8ff404 Added email verification trigger for admin requests
refs https://github.com/TryGhost/Toolbox/issues/387

- When members are added through the Admin client they have to be a part of instance validation process to prevent service misuse.
2022-08-25 14:26:44 +08:00
Naz
7cae68baaa Renamed trigger amount variable
refs https://github.com/TryGhost/Toolbox/issues/387

- Similar reasoning as to previous renames - the variables were named with a single trigger source in mind and now would be confusing with multiple verification trigger sources.
2022-08-25 14:26:44 +08:00
Naz
8892a60948 Renamed verification threshold parameter
refs https://github.com/TryGhost/Toolbox/issues/387

- There will three distinct verification limits soon. To keep the naming clear "configThreshold" would be too generic/confusing to use.
- Introduced jsdoc descriptions for the "source" parameter, which will be corelating with each new config parameter ("apiTriggerThreshold", "importTriggerThreshold", "adminTriggerThreshold", etc.). This should give a better visibility into parameters we are dealing in this area.
2022-08-25 14:26:44 +08:00
Hannah Wolfe
c9864ee63f Added {{search}} theme helper
closes: https://github.com/TryGhost/Team/issues/1732

- adds a theme helper which outputs a working search button with a standard icon
- the icon adopts whatever the current color is from css, and has a set of default styles
- styles can be overridden with !important or the data attribute
- alternatively, any element in a theme may be turned into a search button by adding data-ghost-search
- this is meant to be a simple tool for non-theme-developers to easily add a search icon to their themes in a way that doesn't require css or html knowledge
2022-08-24 21:34:20 +01:00
Hannah Wolfe
96f7b8fdc8 Fixed content-length, again
refs: 203c8036fa
refs: 1fadbacdec
refs: 22fd7f289c

- There is something seriously weird about how content-length changes...
- It's different on CI to local sometimes...
- This particular test should not change IMO
2022-08-24 20:38:35 +01:00
Hannah Wolfe
203c8036fa
Fixed more content-length labs issues
refs: 1fadbacdec
refs: https://github.com/TryGhost/Ghost/commit/x5447985ee2e8a4b497e9c1afbad07

- I'm trying to make it so that changing labs flags doesn't require changes to these snapshot files!
2022-08-24 19:45:20 +01:00
Simon Backx
f124d142c9 Added member attributions to activity feed (#15283)
refs https://github.com/TryGhost/Team/issues/1833
refs https://github.com/TryGhost/Team/issues/1834

We've added the attribution property to subscription and signup events when the
flag is enabled. The attributions resource is fetched by creating multiple relations
on the model, rather than polymorphic as we ran into issues with that as they can't
be nullable/optional.

The parse-member-event structure has been updated to make it easier to work with,
specifically `getObject` is only used when the event is clickable, and there is now a 
join property which makes it easier to join the action and the object.
2022-08-24 11:17:28 -04:00
Daniel Lockyer
2c60340a7d
Fixed maximum call stack exceeded error when filtering Action events
- after a while of browsing around filtering Actions, the endpoint will
  suddenly lock up and start throwing stack exceeded errors
- this is because every time we initialize an Actions model, we push to
  the `candidates` array with a list of the current models
- this was producing a `candidates` array with a length of several
  thousand models after a few clicks, which would cause errors when
  joining the data down the line
- the code was like this because we need to lazy-initialize the models,
  so the order of requiring the Actions model doesn't matter
- this commit switches the code to using a `candidates` function to get
  the models
- this seems to work and the performance cost is negligible given it now
  doesn't error
2022-08-24 17:03:12 +02:00
Fabien "egg" O'Carroll
3c431bd8da Revert "Added member attributions to activity feed (#15283)"
This reverts commit e986b78458.

The tests were not passing for the PR and it was erroneously
merged into main
2022-08-24 11:01:47 -04:00
Emmanuel Gatwech
d9f0db6a22
Replaced Promise.join() with .all() in user model (#14972)
refs: https://github.com/TryGhost/Ghost/issues/14882

- Usage of bluebird is deprecated in favour of using native promises
2022-08-24 15:32:44 +01:00
Navarjun
57a786c63c
Removed bluebird from frontend/meta (#14940)
refs: https://github.com/TryGhost/Ghost/issues/14882

- Usage of bluebird is deprecated in favour of using native promises

Co-authored-by: Navarjun <navarjun@Navarjuns-MBP.hitronhub.home>
2022-08-24 15:28:35 +01:00
Simon Backx
e986b78458
Added member attributions to activity feed (#15283)
refs https://github.com/TryGhost/Team/issues/1833
refs https://github.com/TryGhost/Team/issues/1834

We've added the attribution property to subscription and signup events when the
flag is enabled. The attributions resource is fetched by creating multiple relations
on the model, rather than polymorphic as we ran into issues with that as they can't
be nullable/optional.

The parse-member-event structure has been updated to make it easier to work with,
specifically `getObject` is only used when the event is clickable, and there is now a 
join property which makes it easier to join the action and the object.
2022-08-24 10:11:25 -04:00
Daniel Lockyer
ab8952dd46 v5.11.0 2022-08-24 15:04:56 +01:00
Rishabh
968380132b Allowed setting expiry for complimentary subscriptions
closes https://github.com/TryGhost/Team/issues/1727

- allows site owners to give cardless free trials to members by setting expiry on complimentary subscriptions
- also allows complimentary members to upgrade as paid member
2022-08-24 19:24:31 +05:30
Rishabh
326bb97d2c Enabled free trials via tiers and offers
refs https://github.com/TryGhost/Team/issues/1724
refs https://github.com/TryGhost/Team/issues/1726

- allows site owners to add a default free trial period to their tiers
- allows site owners to create custom offers that allow free trials on tiers
2022-08-24 19:24:31 +05:30
Simon Backx
1f11282228
Added backfill migration for members created events (#15294)
closes https://github.com/TryGhost/Team/issues/1836

- Uses the timestamps from the members table to determine the timestamps for the events
- Clears the table when downgrading to prevent having multiple rows for the same member

Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
2022-08-24 09:38:00 -04:00
Rishabh Garg
9abfae2ddb
Switched off email alerts for subscription cancellation by default (#15304)
refs TryGhost/Team#1825

- all sites are expected to have cancellation alerts off by default
2022-08-24 18:54:00 +05:30
Daniel Lockyer
046fd2bd82 Fixed missing options when creating or editing an Offer
- without this, the model doesn't have the context on who was
  adding/editing it
- this resulted in being unable to store actions for Offers because the
  `actor` is unknown
- this is the pattern we use elsewhere in the code so I've copied it
  into here
2022-08-24 13:56:07 +02:00
Daniel Lockyer
9bdba0250a
Collected Offer CRUD actions
refs https://github.com/TryGhost/Toolbox/issues/356

- this allows collection of CRUD events for Offers but we currently don't
  show them in the UI until it's overhauled to avoid being monotonously
  long
2022-08-24 13:24:13 +02:00
Daniel Lockyer
74e6b4bcf7
Collected Tier CRUD actions
refs https://github.com/TryGhost/Toolbox/issues/356

- this allows collection of CRUD events for Tiers but we currently don't
  show them in the UI until it's overhauled to avoid being monotonously
  long
2022-08-24 12:54:56 +02:00
Hannah Wolfe
21231536cb Removed all remaining bluebird catch predicates
refs: https://github.com/TryGhost/Ghost/issues/14882

- The use of predicates is deprecated, and we're working to remove them from everywhere, so that we can remove bluebird
- This should be the final piece of the puzzle in terms of predicates, from here we can start removing bluebird without concern that a predicate somewhere will explode
- Note: some of this code is poorly tested, but the refactors are very straightforward and minimal
2022-08-24 11:27:09 +01:00
Hannah Wolfe
af94855349 Removed bluebird catch predicates from API endpoints
refs: https://github.com/TryGhost/Ghost/issues/14882

- I found a common pattern where catch predicates were being used to catch non-existent models in destroy methods, and sometimes elsewhere in the API endpoints
- The use of predicates is deprecated, and we're working to remove them from everywhere, so that we can remove bluebird
- In order to still handle these errors correctly, we needed a small change to mw-error-handler so that it can detect EmptyResponse errors from bookshelf, as well as 404s
Note: there is a small change as a result of this - the context on these errors now says "Resource not found" instead of "{ModelName} not found".
- I think this is acceptable for now, as we will be reviewing these errors in more depth later. It's quite easy to make changes, we just have to decide what with proper design input
2022-08-24 11:27:09 +01:00
Daniel Lockyer
c6e62b80fa
Protected against missing resource types
- this shouldn't ever be the case, but if we forget to label the
  resource type, we shouldn't proceed with storing the event because
  it'll throw an error
2022-08-24 11:54:28 +02:00
Daniel Lockyer
76406f78bb
Added primary_name context for added events
refs https://github.com/TryGhost/Toolbox/issues/356

- we should store the `primary_name` on `added` events too because if
  the resource is eventually deleted, we won't have the pretty name to
  refer to it
2022-08-24 08:53:12 +02:00
renovate[bot]
c860b5b715 Update dependency @playwright/test to v1.25.1 2022-08-24 08:42:13 +02:00
Daniel Lockyer
5e38a23976 Fixed Action event resource_type from page to post
refs https://github.com/TryGhost/Toolbox/issues/356
refs 3a9016639c

- I misunderstood the purpose of a column, and changed the values that
  are inserted into it, which broke relation includes in Bookshelf
- I've since reverted that in the commit above but this migration is to
  fixup the data that got stored in the DB
- we want to replace `resource_type` = `page` back to `post`, but then
  use the `context` column as described in the referenced commit to
  store that the type is actually a `page`, so we can link to it
  from the audit log accordingly
- I'm overwriting the `context` column without taking into account the
  current contents but that's ok because this bug existed before we
  started using `context`
2022-08-24 08:37:51 +02:00
Rishabh Garg
c48c65cc88
Added member email alert notification columns for staff (#15276)
refs https://github.com/TryGhost/Team/issues/1825

- adds 3 new columns to users table for storing email alert preferences for member signups/cancellation
- adds column for new member signup alert
- adds column for paid subscription started alert
- adds column for paid subscription canceled alert
- Updated default fixtures and tests for new columns
2022-08-23 22:11:38 +05:30
Daniel Lockyer
7f0996d986
Implemented resource linking in Audit Log
refs https://github.com/TryGhost/Toolbox/issues/356

- we have a very crude version of this before but it just wasn't
  maintainable
- one of the first things I did here was to add `include=resource` on
  the API call, so it returns the fields we need without extra API
  requests
- after we have the id/slug, I could build a route and model array
  dynamically, or return null if we can't redirect to the object (it
  doesn't exist)
2022-08-23 17:48:11 +02:00
Fabien "egg" O'Carroll
73466c1c40 Added ability to filter members on conversion attribution
refs https://github.com/TryGhost/Team/issues/1830
2022-08-23 11:36:56 -04:00
Fabien "egg" O'Carroll
83f2bf4757 Added ability to filter members on signup attribution
refs https://github.com/TryGhost/Team/issues/1831
2022-08-23 11:36:56 -04:00
Georg Grauberger
36d9ae36ae
Added secret handling for webhooks (#13980)
closes: https://github.com/TryGhost/Team/issues/1203
refs: https://github.com/TryGhost/Ghost/issues/9942

- Ensures that the webhook secret is validated and saved in Ghost admin
- Then makes use of this value by optionally adding an X-Ghost-Signature header that effectively signs the webhooks
- This allows for verifying the source of a webhook coming from Ghost is truly Ghost.
- Uses the same pattern as GitHub uses: https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
2022-08-23 16:34:32 +01:00
Daniel Lockyer
f4f757c314
Fixed missing resource type definition
refs 3a9016639c

- this was accidentally missed from the referenced commit
2022-08-23 16:49:11 +02:00
Daniel Lockyer
3a9016639c
Fixed page actions stored under page resource type
refs bde9b84221

- the commit above claimed to fix an issue where actions taken on pages
  were stored using the `post` resource type
- whilst it does that, this actually breaks part of the API because we
  use the `resource_type` to join on tables when doing an
  `include=resource`
- this commit reverts that functionality and instead stores the type in
  the `context` field so we can still differentiate between pages and
  posts
2022-08-23 16:39:47 +02:00
Simon Backx
d91d6c1311
Added attribution counts to Pages API (#15289)
fixes https://github.com/TryGhost/Team/issues/1835

This was missed in the initial pass when adding to the Posts API
2022-08-23 10:26:34 -04:00
Hannah Wolfe
4cd210c29c Added post deletion tests using new e2e framework
- copied over and rewrote the deletion test from the legacy file
- added a new test that checks that we get a 404 when attempting to delete an unknown post
- this is a guard to protect and futureproof the API whilst we do refactoring to improve 404 handling from bookshelf
- in turn this is aimed at helping to get rid of a bunch of catch predicates from the API
2022-08-23 14:49:29 +01:00
Hannah Wolfe
a2a71c8e67 Renamed e2e admin post tests to legacy
- I want to start rewriting the post tests using the new e2e framework, but it's quite a big task
- For now I have renamed the existing file, and will use the correct file name for writing modern versions of tests
- Note: I have a specific test that I'd like to add which is far easier to write in the new framework
- This change should facilitate moving forward more with the new framework
2022-08-23 14:49:29 +01:00
Daniel Lockyer
9effa119c6 Implemented context on Actions events
refs https://github.com/TryGhost/Toolbox/issues/356

- in order to show data that we might not necessarily still have around
  (ie. when you delete a post, you might want the title), we're going to
  start utilizing the `context` column
- right now, we store the `primary_name` for deleted events, and we also
  store the `setting` `key` and `group` so we can reference it in the
  audit log
2022-08-23 14:58:41 +02:00
Aileen Nowak
e5b604cca0 Updated camelCase properties in Explore endpoint to be snake_case 2022-08-23 12:04:07 +01:00
Aileen Nowak
4892f1d0d5 Added publication language to admin site endpoint
no issue

- The site locale should be exposed within the public site config in order to handle i18n in third party apps
- Added the locale to Explore service to simplify fetching it when submitting a new site
2022-08-23 12:04:07 +01:00