From e62e0018851d7d4c5ef3480192047bc4f744b110 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 17 May 2013 00:14:19 +0200 Subject: [PATCH] Webcit dupe-zapper A simple duplicate message finder - criterias are the subject, sender, sent date. If they're the same, its a duplicate. Messages are then moved to the trashcan of the current user. --- webcit/static/t/display_main_menu.html | 2 + .../static/t/menu/advanced_roomcommands.html | 1 + webcit/static/zapduplicates.js | 64 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 webcit/static/zapduplicates.js diff --git a/webcit/static/t/display_main_menu.html b/webcit/static/t/display_main_menu.html index 04b155258..c02ea4dc6 100644 --- a/webcit/static/t/display_main_menu.html +++ b/webcit/static/t/display_main_menu.html @@ -1,5 +1,7 @@ + +
diff --git a/webcit/static/t/menu/advanced_roomcommands.html b/webcit/static/t/menu/advanced_roomcommands.html index cdb8e2151..5d6d3fd48 100644 --- a/webcit/static/t/menu/advanced_roomcommands.html +++ b/webcit/static/t/menu/advanced_roomcommands.html @@ -6,4 +6,5 @@
  • +
  • diff --git a/webcit/static/zapduplicates.js b/webcit/static/zapduplicates.js new file mode 100644 index 000000000..d0e7c5612 --- /dev/null +++ b/webcit/static/zapduplicates.js @@ -0,0 +1,64 @@ +function loadZapMessages(transport) +{ + var dupes = ''; + var dupcount = 0; + try { + var data = evalJSON(transport.responseText); + if (!!data && transport.responseText.length < 2) { + alert("Message loading failed"); + } + nummsgs = data['nummsgs']; + msgs = data['msgs']; + var length = msgs.length; + rowArray = new Array(length); // store so they can be sorted + WCLog("Row array length: "+rowArray.length); + for(var x=1; x 800) { + var mvCommand = "g_cmd=MOVE%20" + dupes + "|"+encodeURIComponent('Trash')+"|0"; + new Ajax.Request("ajax_servcmd", { + parameters: mvCommand, + method: 'post', + }); + dupes = ""; + } + + } + + } + + } catch (e) { + window.alert(e+"|"+e.description); + } + var mvCommand = "g_cmd=MOVE%20" + dupes + "|"+encodeURIComponent('Trash')+"|0"; + new Ajax.Request("ajax_servcmd", { + parameters: mvCommand, + method: 'post', + }); + + alert ('deleted: '+dupcount+'messages'); +} + +function TriggerLoadDupes () +{ +// alert("bla"); +// http://127.0.0.1:2000/roommsgs?room=test%20rss&startmsg=0&stopmsg=499&SortBy=Subject&SortOrder=1 + roomName = getTextContent(document.getElementById("rmname")); + var parameters = {'room':roomName, 'startmsg': 0, 'stopmsg': -1, 'SortBy' : 'Subject', 'SortOrder' : 1}; + + new Ajax.Request("roommsgs", { + method: 'get', + onSuccess: loadZapMessages, + parameters: parameters, + sanitize: false, + evalJSON: false, + onFailure: function(e) { alert("Failure: " + e);} + }); +} \ No newline at end of file -- 2.30.2