Difference between revisions of "TruxtonCommunication"

From truxwiki.com
Jump to navigation Jump to search
Line 53: Line 53:
 
=Sample=
 
=Sample=
  
<syntaxhighlight lang="Python" highlight="32-38">
+
<syntaxhighlight lang="Python" line highlight="3-7,9-10,12">
import truxton
+
def add_message(parent_truxton_file):
import shutil
+
  communication = parent_file.newcommunication()
 +
  communication.sent = ticks("2015-08-16T21:31:37-00:00");
 +
  communication.received = communication.sent
 +
  communication.subject = "Dinner at 8?"
 +
  communication.type = truxton.MESSAGE_TYPE_SMS
 +
  communication.save()
  
from datetime import datetime
+
  communication.addparticipant("703.555.1212", truxton.MESSAGE_PARTICIPANT_FROM)
from calendar import timegm
+
  communication.addparticipant("202.555.1212", truxton.MESSAGE_PARTICIPANT_TO)
from pathlib import Path
 
  
EPOCH_AS_FILETIME = 116444736000000000
+
   communication.finished()
HUNDREDS_OF_NANOSECONDS = 10000000
 
 
 
EVENT_TYPE_FBI = 20001
 
 
 
def date_to_filetime(dt):
 
   return EPOCH_AS_FILETIME + (timegm(dt.timetuple()) * HUNDREDS_OF_NANOSECONDS)
 
 
 
def create_event_type(t, id, name):
 
  event_type = t.neweventtype()
 
  event_type.id = id
 
  event_type.name = name
 
  event_type.save()
 
 
 
def add_file(parent_truxton_file, filename):
 
  source_file = open(filename, "rb")
 
  child = parent_truxton_file.newchild()
 
  child.name = Path(filename).name
 
  shutil.copyfileobj(source_file, child)
 
  source_file.close()
 
  child.save()
 
  return child
 
 
 
def add_event(parent_file, start, end, title, description, type):
 
  event = parent_file.newevent()
 
  event.start = date_to_filetime(datetime.fromisoformat(start))
 
  event.end = date_to_filetime(datetime.fromisoformat(end))
 
  event.title = title
 
  event.description = description
 
  event.type = type
 
  event.save()
 
  return event
 
 
 
def add_media(t):
 
  media = t.newmedia()
 
 
 
  media.name = "Public Documents"
 
  media.description = "Publicly available documents"
 
  media.case = "DC-SNAFU-2016.2020"
 
  media.evidencebag = "EV-0937459386623-a"
 
  media.originator = "Jeffrey Jensen"
 
  media.latitude = 38.897661
 
  media.longitude = -77.036458
 
  media.type = truxton.MEDIA_TYPE_LOGICAL_FILES
 
 
 
  if media.save():
 
    print("Media saved")
 
  else:
 
    print("Media not saved")
 
 
 
  return media
 
 
 
def add_ec(parent_file ):
 
  child_file = add_file(parent_file, "JW-v-DOJ-reply-02743.pdf")
 
 
 
  url = child_file.newurl()
 
  url.url = "https://www.judicialwatch.org/documents/jw-v-doj-reply-02743/"
 
  url.localfilename = "JW-v-DOJ-reply-02743.pdf"
 
  url.type = truxton.URL_TYPE_FIREFOX
 
  url.method = truxton.URL_METHOD_TYPE_CLICKED_ON_A_LINK
 
  url.format = truxton.URL_FORMAT_ASCII
 
  url.when = date_to_filetime(datetime.fromisoformat("2020-05-20T00:00:00-05:00"))
 
  url.save()
 
 
 
  add_event( child_file, "2016-07-31T12:00:00-05:00", "2016-07-31T12:00:00-05:00", "Crossfire Hurricane Created", "At FBI HQ", EVENT_TYPE_FBI )
 
  add_event( child_file, "2016-07-27T12:00:00-05:00", "2016-07-27T12:00:00-05:00", "Legat called needing to meet US ambassador", "In London", EVENT_TYPE_FBI )
 
  add_event( child_file, "2016-07-29T12:00:00-05:00", "2016-07-29T12:00:00-05:00", "FBI Receives Downer Info from Legat", "Probably legat London", EVENT_TYPE_FBI )
 
 
 
def main():
 
  t = truxton.create()
 
 
 
  create_event_type(t, EVENT_TYPE_FBI, "FBI Actions" )
 
 
 
  media = add_media(t)
 
 
 
  root_file = media.addroot()
 
  root_file.save()
 
 
 
  add_ec(root_file)
 
 
 
if __name__ == "__main__":
 
  main()
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 14:04, 8 July 2020

This class lets you add to the communication items (email/sms/mms) to Truxton. This will populate the Message, MessageAddress, and other tables in the database.

Attributes and Methods

addparticipant(account, role)

After save() has been called, you add the participants to the message. The account is the phone number or email address or account that participated in the message. The role parameter is the MESSAGE_PARTICIPANT constants.

fileid

The GUID of the file this event came from. This corresponds to the FileID column of the Message table.

finished()

This should be called after you have finished adding pieces to this message.

id

This is the GUID of the event. It becomes non-zero after save() has been called.

mediaid

This is the GUID of the media this event came from. This identifier corresponds to the MediaID of the Message table.

received

When the message was received in FILETIME ticks. This corresponds to the Received column of the Message table.

save()

This will commit the information to the Event table.

sent

When the message was sent in FILETIME ticks. This corresponds to the Sent column of the Message table.

subject

The subject of the message. If the message type is SMS or MMS, this is the text of the message. This corresponds to the Text column of the MessageSubject table.

tag(tag, reason, origin)

This creates a tag associated with this event in Truxton. The tag parameter is a short, one or two word, bit of text that will be displayed in the UI. The reason a sentence explaining why this event was tagged. The origin is either TAG_ORIGIN_AUTOMATIC (1) or TAG_ORIGIN_HUMAN (2). It will return True if the tag was associated with the file, False on failure.

type

The type of message. It is one of the MESSAGE_TYPE constants. This corresponds to the MessageTypeID column of the Message table and should be a value from the ID column of the MessageType table.

Sample

 1 def add_message(parent_truxton_file):
 2   communication = parent_file.newcommunication()
 3   communication.sent = ticks("2015-08-16T21:31:37-00:00");
 4   communication.received = communication.sent
 5   communication.subject = "Dinner at 8?"
 6   communication.type = truxton.MESSAGE_TYPE_SMS
 7   communication.save()
 8 
 9   communication.addparticipant("703.555.1212", truxton.MESSAGE_PARTICIPANT_FROM)
10   communication.addparticipant("202.555.1212", truxton.MESSAGE_PARTICIPANT_TO)
11 
12   communication.finished()