Your appendable data has a maximum size of 100 KiB. You can save the emails you want to keep by adding them your root structured data (which has no size limit). After you save an email, the app deletes that email from your appendable data. Therefore, it won't show up in your inbox anymore.
Contents
Add the email to the root stuctured data
When you click on the "Save" button, the app adds the email you want to save to your saved folder and removes it from your inbox folder.
Update the root structured data
The app updates your root structured data (which now contains the email you just saved) and encrypts it using symmetric encryption.
Copy PATCH /structured-data/:handleId
structured_data_actions.js
Copy export const updateStructuredData = (token, handleId, data, cipherOpts) => ({
type: ACTION_TYPES.UPDATE_STRUCTURED_DATA,
payload: {
request: {
method: 'patch',
url: `/structured-data/${handleId}`,
headers: {
'Authorization': token
},
data: {
cipherOpts,
data: new Buffer(JSON.stringify(data)).toString('base64')
}
}
}
});
Save the root structured data
The app saves your root structured data to the SAFE Network.
Copy POST /structured-data/:handleId
structured_data_actions.js
Copy export const postStructuredData = (token, handleId) => ({
type: ACTION_TYPES.POST_STRUCTURED_DATA,
payload: {
request: {
method: 'post',
url: `/structured-data/${handleId}`,
headers: {
'Authorization': token
}
}
}
});
Get the appendable data of the inbox folder
The app needs to obtain an appendable data handle.
Get a data identifier handle
First, the app fetches a data identifier handle for the appendable data representing your inbox folder.
Copy POST /data-id/appendable-data
data_id_handle_actions.js
Copy export const getAppendableDataIdHandle = (token, name) => ({
type: ACTION_TYPES.GET_STRUCTURED_DATA_ID_HANDLE,
payload: {
request: {
method: 'post',
url: '/data-id/appendable-data',
headers: {
'Authorization': token
},
data: {
isPrivate: true,
name
}
}
}
});
The name of the appendable data is obtained by hashing your email ID:
app_utils.js
Copy export const hashEmailId = emailId => {
return crypto.createHash('sha256').update(emailId).digest('base64');
};
Get an appendable data handle
The app fetches an appendable data handle using the data identifier handle representing your inbox folder.
Copy GET /appendable-data/handle/:dataIdHandle
appendable_data_actions.js
Copy export const fetchAppendableDataHandle = (token, dataIdHandle) => { // id => appendable data id
return {
type: ACTION_TYPES.FETCH_APPENDABLE_DATA_HANDLER,
payload: {
request: {
url: `/appendable-data/handle/${dataIdHandle}`,
headers: {
'Authorization': token,
'Is-Private': true
}
}
}
};
};
Drop the data identifier handle
The app drops the data identifier handle for the appendable data representing your inbox folder.
Copy DELETE /data-id/:handleId
data_id_handle_actions.js
Copy export const dropHandler = (token, handleId) => ({
type: ACTION_TYPES.DROP_HANDLER,
payload: {
request: {
method: 'delete',
url: `/data-id/${handleId}`,
headers: {
'Authorization': token
}
}
}
});
Remove the email from the appendable data
The app removes the email you just saved from your appendable data. This moves the email to the deleted_data
field of the appendable data.
Copy DELETE /appendable-data/:handleId/:index
appendable_data_actions.js
Copy export const removeFromAppendableData = (token, handleId, index) => {
return {
type: ACTION_TYPES.REMOVE_FROM_APPENDABLE_DATA,
payload: {
request: {
method: 'delete',
url: `/appendable-data/${handleId}/${index}`,
headers: {
'Authorization': token
}
}
}
};
};
Save the appendable data
The app saves your appendable data by sending a POST request to the SAFE Network.
Copy POST /appendable-data/:handleId
appendable_data_actions.js
Copy export const postAppendableData = (token, handleId) => ({
type: ACTION_TYPES.POST_APPENDABLE_DATA,
payload: {
request: {
method: 'post',
url: `/appendable-data/${handleId}`,
headers: {
'Authorization': token
}
}
}
});
Clear the deleted data of the appendable data
The app clears the deleted_data
field of your appendable data.
Copy DELETE /appendable-data/clear-deleted-data/:handleId
appendable_data_actions.js
Copy export const clearDeletedData = (token, handleId) => ({
type: ACTION_TYPES.CLEAR_DELETE_DATA,
payload: {
request: {
method: 'delete',
url: `/appendable-data/clear-deleted-data/${handleId}`,
headers: {
'Authorization': token
}
}
}
});
Save the appendable data (again)
The app saves your appendable data by sending a POST request to the SAFE Network.
Copy POST /appendable-data/:handleId
appendable_data_actions.js
Copy export const postAppendableData = (token, handleId) => ({
type: ACTION_TYPES.POST_APPENDABLE_DATA,
payload: {
request: {
method: 'post',
url: `/appendable-data/${handleId}`,
headers: {
'Authorization': token
}
}
}
});
Drop the appendable data handle
Copy DELETE /appendable-data/handle/:handleId
appendable_data_actions.js
Copy export const dropAppendableDataHandle = (token, handleId) => ({
type: ACTION_TYPES.DROP_APPENDABLE_DATA_HANDLE,
payload: {
request: {
method: 'delete',
url: `/appendable-data/handle/${handleId}`,
headers: {
'Authorization': token
}
}
}
});