Skip to content

Commit

Permalink
specify sequelize association
Browse files Browse the repository at this point in the history
  • Loading branch information
hdiniz committed May 13, 2024
1 parent 0d31ba0 commit 45b4d67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/models/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Order extends Model<InferAttributes<Order>, InferCreationAttributes<Order>
await models.Activity.create({
type: ActivityTypes.ORDER_PENDING_EXPIRED,
UserId: user?.id,
CollectiveId: toAccount.id,
CollectiveId: toAccount?.id,
FromCollectiveId: this.FromCollectiveId,
OrderId: this.id,
HostCollectiveId: host?.id,
Expand Down
22 changes: 12 additions & 10 deletions server/paymentProviders/stripe/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export const chargeDisputeCreated = async (event: Stripe.Event) => {
{
model: models.Collective,
as: 'collective',
include: [{ model: models.Collective, as: 'host', required: false }],
include: [{ model: models.Collective, as: 'host', foreignKey: 'HostCollectiveId', required: true }],
},
{ model: models.Collective, as: 'fromCollective' },
models.Tier,
Expand Down Expand Up @@ -364,7 +364,7 @@ export const chargeDisputeCreated = async (event: Stripe.Event) => {
HostCollectiveId: order.collective.HostCollectiveId,
data: {
order: order.info,
fromAccountInfo: order.data.fromAccountInfo,
fromAccountInfo: order.data?.fromAccountInfo,
fromCollective: order.fromCollective.info,
host: order.collective.host?.info,
toCollective: order.collective.info,
Expand Down Expand Up @@ -420,7 +420,7 @@ export const chargeDisputeClosed = async (event: Stripe.Event) => {
{
model: models.Collective,
as: 'collective',
include: [{ model: models.Collective, as: 'host', required: false }],
include: [{ model: models.Collective, as: 'host', foreignKey: 'HostCollectiveId', required: true }],
},
{ model: models.Collective, as: 'fromCollective' },
models.Tier,
Expand Down Expand Up @@ -448,7 +448,7 @@ export const chargeDisputeClosed = async (event: Stripe.Event) => {
HostCollectiveId: order.collective.HostCollectiveId,
data: {
order: order.info,
fromAccountInfo: order.data.fromAccountInfo,
fromAccountInfo: order.data?.fromAccountInfo,
fromCollective: order.fromCollective.info,
host: order.collective.host?.info,
toCollective: order.collective.info,
Expand Down Expand Up @@ -596,9 +596,10 @@ export const reviewOpened = async (event: Stripe.Event) => {
{
model: models.Collective,
as: 'collective',
include: [{ model: models.Collective, as: 'collective', required: true }],
foreignKey: 'CollectiveId',
include: [{ model: models.Collective, as: 'host', foreignKey: 'HostCollectiveId', required: true }],
},
{ model: models.Collective, as: 'fromCollective' },
{ model: models.Collective, as: 'fromCollective', foreignKey: 'FromCollectiveId' },
models.Tier,
],
},
Expand All @@ -620,7 +621,7 @@ export const reviewOpened = async (event: Stripe.Event) => {
HostCollectiveId: order.collective.HostCollectiveId,
data: {
order: order.info,
fromAccountInfo: order.data.fromAccountInfo,
fromAccountInfo: order.data?.fromAccountInfo,
fromCollective: order.fromCollective.info,
host: order.collective.host.info,
toCollective: order.collective.info,
Expand Down Expand Up @@ -678,10 +679,11 @@ export const reviewClosed = async (event: Stripe.Event) => {
{ model: models.Subscription, required: false },
{
model: models.Collective,
as: 'collective',
foreignKey: 'CollectiveId',
include: [{ model: models.Collective, foreignKey: 'HostCollectiveId', required: false }],
include: [{ model: models.Collective, as: 'host', foreignKey: 'HostCollectiveId', required: true }],
},
{ model: models.Collective, as: 'fromCollective' },
{ model: models.Collective, as: 'fromCollective', foreignKey: 'FromCollectiveId' },
models.Tier,
],
},
Expand Down Expand Up @@ -721,7 +723,7 @@ export const reviewClosed = async (event: Stripe.Event) => {
HostCollectiveId: order.collective.HostCollectiveId,
data: {
order: order.info,
fromAccountInfo: order.data.fromAccountInfo,
fromAccountInfo: order.data?.fromAccountInfo,
fromCollective: order.fromCollective.info,
host: order.collective.host?.info,
toCollective: order.collective.info,
Expand Down

0 comments on commit 45b4d67

Please sign in to comment.