payment confirmation for renter after rental request approval, first listing celebration email, removed burstprotection for google places autocomplete, renamed email templates
This commit is contained in:
@@ -225,16 +225,37 @@ router.post("/", authenticateToken, requireVerifiedEmail, async (req, res) => {
|
||||
{
|
||||
model: User,
|
||||
as: "owner",
|
||||
attributes: ["id", "username", "firstName", "lastName"],
|
||||
attributes: ["id", "username", "firstName", "lastName", "email", "stripeConnectedAccountId"],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Check if this is the owner's first listing
|
||||
const ownerItemCount = await Item.count({
|
||||
where: { ownerId: req.user.id }
|
||||
});
|
||||
|
||||
// If first listing, send celebration email
|
||||
if (ownerItemCount === 1) {
|
||||
try {
|
||||
const emailService = require("../services/emailService");
|
||||
await emailService.sendFirstListingCelebrationEmail(
|
||||
itemWithOwner.owner,
|
||||
itemWithOwner
|
||||
);
|
||||
console.log(`First listing celebration email sent to owner ${req.user.id}`);
|
||||
} catch (emailError) {
|
||||
// Log but don't fail the item creation
|
||||
console.error('Failed to send first listing celebration email:', emailError.message);
|
||||
}
|
||||
}
|
||||
|
||||
const reqLogger = logger.withRequestId(req.id);
|
||||
reqLogger.info("Item created", {
|
||||
itemId: item.id,
|
||||
ownerId: req.user.id,
|
||||
itemName: req.body.name
|
||||
itemName: req.body.name,
|
||||
isFirstListing: ownerItemCount === 1
|
||||
});
|
||||
|
||||
res.status(201).json(itemWithOwner);
|
||||
|
||||
Reference in New Issue
Block a user