Skip to content

Commit

Permalink
2.5.15 fix post customer me email duplicate and add itunes and play s…
Browse files Browse the repository at this point in the history
…tore URL to app config
  • Loading branch information
pauljonescodes committed Feb 1, 2024
1 parent 768ce06 commit b923b97
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@
"typeorm": "node --loader ts-node/esm -r tsconfig-paths/register ./node_modules/typeorm/cli.js"
},
"type": "module",
"version": "2.5.14"
"version": "2.5.15"
}
6 changes: 5 additions & 1 deletion src/database/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import 'reflect-metadata';
import { DataSource, DataSourceOptions } from 'typeorm';
import { fileURLToPath } from 'url';

// For local:
// FOR MIGRATION GENERATION UNCOMMENT:
//
// import fs from 'fs';
// const envConfig = fs.readFileSync('.env.staging');
// for (const line of envConfig.toString().split('\n')) {
// const [key, value] = line.split('=');
// process.env[key] = value;
// }
//
// THEN RUN:
// npm run migration:generate -- src/database/migrations/SomeName

export const AppDataSource = new DataSource({
type: process.env.DATABASE_TYPE,
Expand Down
33 changes: 33 additions & 0 deletions src/database/migrations/1706827780693-PreferRelatedApplications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class PreferRelatedApplications1706827780693
implements MigrationInterface
{
name = 'PreferRelatedApplications1706827780693';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "app_config" ADD "preferRelatedApplications" boolean DEFAULT false`,
);
await queryRunner.query(
`ALTER TABLE "app_config" ADD "playAppUrl" character varying`,
);
await queryRunner.query(
`ALTER TABLE "app_config" ADD "playAppId" character varying`,
);
await queryRunner.query(
`ALTER TABLE "app_config" ADD "itunesUrl" character varying`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "app_config" DROP COLUMN "itunesUrl"`);
await queryRunner.query(`ALTER TABLE "app_config" DROP COLUMN "playAppId"`);
await queryRunner.query(
`ALTER TABLE "app_config" DROP COLUMN "playAppUrl"`,
);
await queryRunner.query(
`ALTER TABLE "app_config" DROP COLUMN "preferRelatedApplications"`,
);
}
}
2 changes: 1 addition & 1 deletion src/i18n/en/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"postCustomerMe": {
"html": "<p>Hello,</p><p>Welcome to {merchant.squareBusinessName} on MyOrderApp!</p><p>We're thrilled to have you with us. Dive in and enjoy hassle-free ordering from {merchant.squareBusinessName}. Should you have questions or encounter any issues with your orders, don't hesitate to contact us at <a href='mailto:{supportEmail}'>{supportEmail}</a>.</p><p>Happy ordering!</p><p>Best regards,</p><p>The MyOrderApp Team</p>",
"subject": "Welcome to {merchant.squareBusinessName} on MyOrderApp,!",
"subject": "Welcome to {merchant.squareBusinessName} on MyOrderApp!",
"text": "Hello,\n\nThank you for choosing {merchant.squareBusinessName} on MyOrderApp! Explore and experience smooth and efficient ordering from us. If you need any assistance or have inquiries, please email us at {supportEmail}.\n\nHappy shopping!\n\nBest regards,\nThe MyOrderApp Team"
},
"postMerchantMe": {
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function bootstrap() {
app,
new DocumentBuilder()
.setTitle('MyOrderApp Square API')
.setVersion('2.5.14')
.setVersion('2.5.15')
.addBearerAuth()
.addApiKey(
{ type: 'apiKey', name: config.headerApiKey, in: 'header' },
Expand Down Expand Up @@ -126,7 +126,7 @@ async function bootstrap() {
app,
new DocumentBuilder()
.setTitle('MyOrderApp Admin API')
.setVersion('2.5.14')
.setVersion('2.5.15')
.addBearerAuth()
.addApiKey(
{ type: 'apiKey', name: config.headerApiKey, in: 'header' },
Expand Down
9 changes: 0 additions & 9 deletions src/moa-square/controllers/customers.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,6 @@ export class CustomersController {
merchantIdOrPath: merchantIdOrPath,
});

try {
await this.mailService.sendPostCustomerMeOrThrow({
user,
merchant,
});
} catch (error) {
this.logger.error(error);
}

const found = await this.service.findOne({
where: { id: created.id },
relations: {
Expand Down
20 changes: 20 additions & 0 deletions src/moa-square/entities/app-config.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ export class AppConfigEntity extends BaseEntity {
@Column({ nullable: true, default: 7 })
categoryCollapseThreshold?: number;

@ApiProperty({
required: false,
nullable: true,
type: Boolean,
})
@Column({ nullable: true, default: false })
preferRelatedApplications?: boolean;

@ApiProperty({ required: false, type: String, nullable: true })
@Column({ nullable: true })
playAppUrl?: string;

@ApiProperty({ required: false, type: String, nullable: true })
@Column({ nullable: true })
playAppId?: string;

@ApiProperty({ required: false, type: String, nullable: true })
@Column({ nullable: true })
itunesUrl?: string;

/* App Icon */

@Column({ nullable: true })
Expand Down
11 changes: 11 additions & 0 deletions src/moa-square/services/customers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Customer as SquareCustomer } from 'square';
import { FindOptionsRelations, Repository } from 'typeorm';
import { EntityRepositoryService } from '../../database/entity-repository-service.js';
import { I18nTranslations } from '../../i18n/i18n.generated.js';
import { MailService } from '../../mail/mail.service.js';
import { UsersService } from '../../users/users.service.js';
import { CustomerPatchBody } from '../dto/customers/customer-patch-body.dto.js';
import { CustomerEntity } from '../entities/customer.entity.js';
Expand All @@ -29,6 +30,7 @@ export class CustomersService extends EntityRepositoryService<CustomerEntity> {
private readonly squareService: NestSquareService,
private readonly merchantsService: MerchantsService,
private readonly locationsService: LocationsService,
private readonly mailService: MailService,
private readonly i18n: I18nService<I18nTranslations>,
) {
const logger = new Logger(CustomersService.name);
Expand Down Expand Up @@ -194,6 +196,15 @@ export class CustomersService extends EntityRepositoryService<CustomerEntity> {
}),
);

try {
await this.mailService.sendPostCustomerMeOrThrow({
user,
merchant,
});
} catch (error) {
this.logger.error(error);
}

return await this.save(customer);
}

Expand Down

0 comments on commit b923b97

Please sign in to comment.