mirror of
https://github.com/Mail-0/Zero.git
synced 2026-07-01 08:16:28 +00:00
* fix: remove tracked node_modules/.bin files * added to .gitignore * update compose * feat: Add AI brain and summary features for email - Implemented EnableBrain action to subscribe to mail gateway - Created GetSummary action to retrieve email thread summaries - Added useSummary hook for fetching summaries - Introduced mail0_summary database table - Added Brain button to app sidebar for enabling AI features * fix: Improve null safety and remove unused imports - Fixed potential null access in thread-display by checking array first - Removed unused markAsReadAction import in use-threads hook - Removed unnecessary cache deletion logic in IndexedDB storage provider - Removed threadId from ParsedMessage type definition * fix: Use environment variable for brain gateway URL - Replace hardcoded mail gateway URL with configurable environment variable - Improve flexibility and configuration of brain subscription endpoint * big push for connections and server actions: - unread count ✅ - remove `/connect-email` ✅ - update redirects and callbacks to `/settings/connections` ✅ - make everything else server actions ✅ - remove old route.ts files ✅ * feat: Improve HTML text extraction and email parsing - Added Cheerio for robust HTML text extraction in extractTextFromHTML - Enhanced null safety in Google email driver for sender name and subject - Updated mail list and threads hooks to handle potential undefined values - Improved text cleaning and handling of edge cases in email parsing * editor working * compose and video * fix: remove t3-oss env * update max results to 10 per requst * zero button floating sidebar * lots of changes: - removes old mail compose modal - smaller upload limit - useReducer on components with lots of state - image logos for some file types (still more to add) - resolve comments from previous review * add logos * straing to staging * improvements to create ui (#345) * made create wider * send to multiple emails and new ui for 'to' list * add icons for file upload (#346) * added icon for figma icon * added else ifs for other icons * add file name to the getLogo func * fix figma if statement * fix figma * fix excel * remove console logs * fix back to original component * file icons * ui tweaks --------- Co-authored-by: Nizzy <nizabizaher@gmail.com> Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com> * fix: sidebar and settings page ui fixes (#348) * fixes * define to emails * rotate on hover logo * early access count on homepage * updated readme --------- Co-authored-by: Sijan Mainali <sijanmainali2@gmail.com> Co-authored-by: Adam <x_1337@outlook.com> Co-authored-by: Nizzy <nizabizaher@gmail.com> Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com> Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com>
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import { createImageUpload } from "novel";
|
|
import { toast } from "sonner";
|
|
|
|
const onUpload = (file: File) => {
|
|
const promise = fetch("/api/upload", {
|
|
method: "POST",
|
|
headers: {
|
|
"content-type": file?.type || "application/octet-stream",
|
|
"x-vercel-filename": file?.name || "image.png",
|
|
},
|
|
body: file,
|
|
});
|
|
|
|
return new Promise((resolve, reject) => {
|
|
toast.promise(
|
|
promise.then(async (res) => {
|
|
// Successfully uploaded image
|
|
if (res.status === 200) {
|
|
const { url } = (await res.json()) as { url: string };
|
|
// preload the image
|
|
const image = new Image();
|
|
image.src = url;
|
|
image.onload = () => {
|
|
resolve(url);
|
|
};
|
|
// No blob store configured
|
|
} else if (res.status === 401) {
|
|
resolve(file);
|
|
throw new Error(
|
|
"`BLOB_READ_WRITE_TOKEN` environment variable not found, reading image locally instead.",
|
|
);
|
|
// Unknown error
|
|
} else {
|
|
throw new Error("Error uploading image. Please try again.");
|
|
}
|
|
}),
|
|
{
|
|
loading: "Uploading image...",
|
|
success: "Image uploaded successfully.",
|
|
error: (e) => {
|
|
reject(e);
|
|
return e.message;
|
|
},
|
|
},
|
|
);
|
|
});
|
|
};
|
|
|
|
export const uploadFn = createImageUpload({
|
|
onUpload,
|
|
validateFn: (file) => {
|
|
if (file.size / 1024 / 1024 > 20) {
|
|
toast.error("File size too big (max 20MB).");
|
|
return false;
|
|
}
|
|
|
|
const allowedTypes = [
|
|
"image/*",
|
|
"application/pdf",
|
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
"application/msword",
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
"application/vnd.ms-excel",
|
|
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
"application/vnd.ms-powerpoint",
|
|
"text/plain",
|
|
"text/html",
|
|
"text/csv",
|
|
"application/zip",
|
|
"application/x-zip-compressed",
|
|
"application/rtf",
|
|
"audio/mpeg",
|
|
"audio/wav",
|
|
"video/mp4",
|
|
"video/mpeg",
|
|
];
|
|
|
|
if (!allowedTypes.includes(file.type)) {
|
|
toast.error("File type not supported in emails.");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
},
|
|
});
|