Skip to content

Commit 45e927f

Browse files
committed
remove file attachment code from sync server
1 parent 49041bf commit 45e927f

File tree

1 file changed

+8
-39
lines changed

1 file changed

+8
-39
lines changed

server/src/index.js

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -135,35 +135,6 @@ app.post('/api/sync', async (req, res) => {
135135
});
136136
}
137137

138-
for (const note of notes) {
139-
if (note.attachments) {
140-
let totalSize = 0;
141-
for (const attachment of note.attachments) {
142-
const fileSize = Buffer.from(attachment.data, 'base64').length;
143-
if (fileSize > MAX_FILE_SIZE) {
144-
return res.status(400).json({
145-
error: 'File size exceeds limit',
146-
details: {
147-
fileName: attachment.name,
148-
size: fileSize,
149-
limit: MAX_FILE_SIZE
150-
}
151-
});
152-
}
153-
totalSize += fileSize;
154-
}
155-
if (totalSize > MAX_TOTAL_ATTACHMENTS_SIZE) {
156-
return res.status(400).json({
157-
error: 'Total attachments size exceeds limit',
158-
details: {
159-
totalSize,
160-
limit: MAX_TOTAL_ATTACHMENTS_SIZE
161-
}
162-
});
163-
}
164-
}
165-
}
166-
167138
await db.collection('users').updateOne(
168139
{ public_key },
169140
{
@@ -241,8 +212,7 @@ async function processNotes(public_key, incoming_notes) {
241212
timestamp: note.timestamp,
242213
signature: note.signature,
243214
public_key,
244-
deleted: note.deleted,
245-
attachments: note.attachments
215+
deleted: note.deleted
246216
}
247217
},
248218
{ upsert: true }
@@ -269,14 +239,13 @@ async function processNotes(public_key, incoming_notes) {
269239
})
270240
.toArray();
271241

272-
results.notes = allNotes.map(note => ({
273-
id: note.id,
274-
data: note.data,
275-
nonce: note.nonce,
276-
timestamp: note.timestamp,
277-
signature: note.signature,
278-
attachments: note.attachments
279-
}));
242+
results.notes = allNotes.map(note => ({
243+
id: note.id,
244+
data: note.data,
245+
nonce: note.nonce,
246+
timestamp: note.timestamp,
247+
signature: note.signature
248+
}));
280249

281250
return results;
282251
});

0 commit comments

Comments
 (0)