Skip to content

Instantly share code, notes, and snippets.

@MichaelBlume
Created March 24, 2016 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelBlume/ccce1b7487adee85d1ee to your computer and use it in GitHub Desktop.
Save MichaelBlume/ccce1b7487adee85d1ee to your computer and use it in GitHub Desktop.
drops all messages older than some date from a textsecure backup
(def cutoff
(clj-time.coerce/to-long
(clj-time.core/date-time 2015 4 3 5 54)))
(with-open [input (java.io.FileInputStream.
"/Users/michael.blume/TextSecurePlaintextBackup.xml")
output (java.io.FileWriter.
"/Users/michael.blume/betterbackup.xml")]
(-> input
clojure.data.xml/parse
(update-in [:content] (fn [messages]
(filter #(-> % :attrs :date Long/parseLong (> cutoff)) messages)))
(clojure.data.xml/emit output)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment