GeezerVison is showing github.com — Bulk Delete Threads · Issue #434 · NdoleStudio/httpsms
DescriptionWhen incoming messages are turned on, then the web UI can be come cluttered. There should be an option to bulk delete threads without opening them one by one. ActivityAchoArnold commented on May 16, 2024 @ilovefreesw I'm curious, how many thread do you really have that requires bulk delete?
Also, this is the reason why I created the archive feature, You can archive phone numbers who spam you so that you won't see them under your list of threads. ilovefreesw commented on May 17, 2024 Basically, I get SMS from bank, promotions, some personal sms from friends or acquaintances that I don't want to sync to httpsms, and more. Currently I have around 210 threads this month only. AchoArnold commented on May 17, 2024 I see I'll keep this open to be implemented sometime in the future. In the meantime you can use the API to delete all the threads in a loop thread delete API AchoArnold commented on Jun 9, 2024 ilovefreesw commented on Oct 5, 2024 I use this script... leaving it here .. might help someone else:
async function deleteThreadsFromAnchorLinks(selector, apiKey) {
if (!selector || typeof selector !== 'string') {
throw new Error('Invalid selector provided.');
}
if (!apiKey || typeof apiKey !== 'string') {
throw new Error('Invalid or missing API key.');
}
const baseUrl = 'https://**YourAPIDomain**/v1/message-threads/';
try {
const elements = document.querySelectorAll(selector);
const threadIds = [];
for (const element of elements) {
const url = element.href;
if (typeof url !== 'string') {
console.warn(`Skipping invalid URL: ${url}`);
continue;
}
const urlParts = url.split('/');
const lastPart = urlParts[urlParts.length - 1];
// Extract thread ID using a regular expression (more reliable)
const threadIdMatch = lastPart.match(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i);
if (threadIdMatch) {
threadIds.push(threadIdMatch[0]);
} else {
console.warn(`Unable to extract thread ID from URL: ${url}`);
}
}
if (threadIds.length === 0) {
throw new Error('No thread IDs found in the anchor links.');
}
const deletionPromises = threadIds.map(async (threadId) => {
const url = `${baseUrl}${threadId}`;
const options = {
method: 'DELETE',
headers: {
'accept': 'application/json',
'x-api-Key': apiKey,
},
};
const response = await fetch(url, options);
if (!response.ok) {
console.error(`Error deleting thread ${threadId}: ${await response.text()}`);
} else {
console.log(`Thread ${threadId} deleted successfully.`);
}
});
await Promise.all(deletionPromises); // Wait for all deletions to finish
} catch (error) {
console.error('Error deleting threads:', error);
}
}
// Replace with your actual CSS selector and API key
const selector = "div.v-item-group a"; // Adjust this to match your HTML structure
const apiKey = '**YourAPIKey**'; // Replace with your actual API key
deleteThreadsFromAnchorLinks(selector, apiKey)
.then(() => console.log('All threads deleted (if successful).'))
.catch((error) => console.error('Error deleting threads:', error));
Just have to replace API Key and API Domain. Paste the script in console on the threads page and let it delete all of them. AchoArnold commented on Oct 7, 2024 Reacted by Sul Reacted by Sul
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|