Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
msveshnikov committed Apr 29, 2024
1 parent 598fc6a commit 5c8b10c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
6 changes: 3 additions & 3 deletions server/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export async function handleIncomingEmails() {
email: emailFrom?.from?.value?.[0]?.address,
});
if (user && emailBody) {
// Check if the email has attachments
const attachments = emailFrom.attachments;
if (attachments && attachments.length > 0) {
for (const attachment of attachments) {
Expand All @@ -65,7 +64,8 @@ export async function handleIncomingEmails() {
emailBody += `\n\n${docResult.value}`;
} else if (
fileType === "application/xlsx" ||
fileType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
fileType ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
) {
const workbook = xlsx.read(fileBytes, { type: "buffer" });
const sheetNames = workbook.SheetNames;
Expand All @@ -82,7 +82,7 @@ export async function handleIncomingEmails() {
}

const response = await getTextClaude(
//TODO: some user context and attachments
//TODO: some user context
emailFrom.subject + "\n" + emailBody,
0.2,
null,
Expand Down
16 changes: 6 additions & 10 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ app.get("/user", verifyToken, async (req, res) => {
res.status(500).json({ error: "Server error" });
}
});

app.get("/stats", verifyToken, async (req, res) => {
if (!req.user.admin) {
return res.status(401).json({ error: "This is admin only route" });
Expand Down Expand Up @@ -512,15 +513,11 @@ async function handleSubscriptionUpdate(subscription) {
console.error("User not found");
return;
}
if (subscription.status === "active") {
user.subscriptionStatus = "active";
} else if (subscription.status === "trialing") {
user.subscriptionStatus = "trialing";
} else if (subscription.status === "past_due") {
user.subscriptionStatus = "past_due";
} else if (subscription.status === "canceled") {
user.subscriptionStatus = "canceled";
if (user.subscriptionStatus === "past_due" && subscription.status === "trialing") {
console.error("User has past_due, trialing not possible");
return;
}
user.subscriptionStatus = subscription.status;
user.subscriptionId = subscription.id;
await user.save();
}
Expand Down Expand Up @@ -691,5 +688,4 @@ process.on("uncaughtException", (err, origin) => {
console.error(`Caught exception: ${err}`, `Exception origin: ${origin}`);
});


setInterval(handleIncomingEmails, 60 * 1000);
setInterval(handleIncomingEmails, 60 * 1000);
28 changes: 15 additions & 13 deletions src/components/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,22 @@ const Settings = ({ user, handleCancelSubscription, handleCloseSettingsModal, se
</Link>
</>
) : (
<Link
href={"https://buy.stripe.com/28oaGDclzeEfgUgcMM?prefilled_email=" + user.email}
target="_blank"
rel="noopener"
>
<Button
onClick={handleCloseSettingsModal}
variant="contained"
color="primary"
sx={{ mt: 1 }}
user.subscriptionStatus !== "past_due" && (
<Link
href={"https://buy.stripe.com/28oaGDclzeEfgUgcMM?prefilled_email=" + user.email}
target="_blank"
rel="noopener"
>
{t("Start Subscription")}
</Button>
</Link>
<Button
onClick={handleCloseSettingsModal}
variant="contained"
color="primary"
sx={{ mt: 1 }}
>
{t("Start Subscription")}
</Button>
</Link>
)
)}
</Grid>

Expand Down

0 comments on commit 5c8b10c

Please sign in to comment.