Difference between revisions of "TruxtonCommunication"

From truxwiki.com
Jump to navigation Jump to search
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This class lets you add to the communication items (email/sms/mms) to Truxton.
 
This class lets you add to the communication items (email/sms/mms) to Truxton.
This will populate the <code>Message</code>, <code>MessageAddress</code>, and other tables in the database.
+
This will populate the <code>[Message]</code>, <code>[MessageAddress]</code>, and other tables in the database.
 
=Attributes and Methods=
 
=Attributes and Methods=
==<code>id</code>==
+
==<code>addnote(text: str) -> boolean</code>==
 +
This adds an investigator's note.
 +
The <code>text</code> parameter is the contents of the note.
 +
It will return
 +
[https://docs.python.org/3.10/library/constants.html?highlight=false#True True] if the tag was associated with the communication, [https://docs.python.org/3.10/library/constants.html?highlight=false#False False] on failure.
 +
The note is stored in the <code>[InvestigatorNote]</code> table in the database.
 +
 
 +
==<code>addpiece(file: object, origin: int, instance: int) -> boolean</code>==
 +
This allows you to add a [[TruxtonFileIO|file]] or [[TruxtonChildFileIO|child file]] as part of a communication.
 +
The <code>origin</code> parameter should be one of the [[Origin|defined constants.]]
 +
 
 +
==<code>addparticipant(account: str, name: str, role: int, artifact_type: int) -> str</code>==
 +
After <code>save()</code> has been called, you add the participants to the message.
 +
The <code>account</code> is the phone number or email address or account that participated in the message.
 +
The <code>name</code> is the name of the person associated with this account or an empty string.
 +
The <code>role</code> parameter is the <code>[[Message Participants|MESSAGE_PARTICIPANT]]</code> constants.
 +
The <code>artifact_type</code> is used when the underlying function automatically adds the account to the artifacts table.
 +
It should be one of the [[Entity Types|defined constants]].
 +
It should be a value that matches the <code>[ID]</code> column of the <code>[MessageAddressType]</code> table.
 +
 
 +
==<code>fileid: str</code>==
 +
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file this event came from.
 +
This corresponds to the <code>[FileID]</code> column of the <code>[Message]</code> table.
 +
 
 +
==<code>finished() -> boolean</code>==
 +
This should be called after you have finished adding all of the pieces to this message.
 +
It will return [https://docs.python.org/3.10/library/constants.html#True True] if the record was saved to the database, [https://docs.python.org/3.10/library/constants.html#False False] if there was an error.
 +
 
 +
==<code>id: str</code>==
 
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the event.
 
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the event.
 
It becomes non-zero after <code>save()</code> has been called.
 
It becomes non-zero after <code>save()</code> has been called.
  
==<code>fileid</code>==
+
==<code>mediaid: str</code>==
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file this event came from.
 
This corresponds to the <code>FileID</code> column of the <code>Message</code> table.
 
 
 
==<code>mediaid</code>==
 
 
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media this event came from.
 
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media this event came from.
This identifier corresponds to the <code>MediaID</code> of the <code>Message</code> table.
+
This identifier corresponds to the <code>[MediaID]</code> of the <code>[Message]</code> table.
 
 
==<code>received</code>==
 
When the message was received in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 
This corresponds to the <code>Received</code> column of the <code>Message</code> table.
 
  
==<code>sent</code>==
+
==<code>received: [https://docs.python.org/3/library/datetime.html datetime]</code>==
When the message was sent in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
+
When the message was received.
This corresponds to the <code>Sent</code> column of the <code>Message</code> table.
+
This value can be set with either a datetime value or an integer representing [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 +
This corresponds to the <code>[Received]</code> column of the <code>[Message]</code> table.
  
==<code>type</code>==
+
==<code>save() -> boolean</code>==
The type of message.
+
This will commit the information to the <code>[Message]</code> table.
It can be one of the Message Type constants.
+
It will return [https://docs.python.org/3.10/library/constants.html#True True] if the record was saved to the database, [https://docs.python.org/3/library/constants.html#False False] if there was an error.
  
This corresponds to the <code>Sent</code> column of the <code>Message</code> table and should be a value from the <code>ID</code> column of the <code>MessageType</code> table.
+
==<code>sent: [https://docs.python.org/3/library/datetime.html datetime]</code>==
 +
When the message was sent.
 +
This value can be set with either a datetime value or an integer representing [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 +
This corresponds to the <code>[Sent]</code> column of the <code>[Message]</code> table.
  
==<code>subject</code>==
+
==<code>subject: str</code>==
 
The subject of the message.
 
The subject of the message.
 
If the message type is SMS or MMS, this is the text of the message.
 
If the message type is SMS or MMS, this is the text of the message.
 +
This corresponds to the <code>[Text]</code> column of the <code>[MessageSubject]</code> table.
  
==<code>save()</code>==
+
==<code>tag(tag: str, reason: str, origin: int) -> boolean</code>==
This will commit the information to the <code>Event</code> table.
 
 
 
==<code>tag(tag, reason, origin)</code>==
 
 
This creates a tag associated with this event in Truxton.
 
This creates a tag associated with this event in Truxton.
 
The <code>tag</code> parameter is a short, one or two word, bit of text that will be displayed in the UI.
 
The <code>tag</code> parameter is a short, one or two word, bit of text that will be displayed in the UI.
The <code>reason</code> a sentence explaining why this event was tagged.
+
The <code>reason</code> is a sentence explaining why this event was tagged.
 
The <code>origin</code> is either <code>TAG_ORIGIN_AUTOMATIC</code> (1) or <code>TAG_ORIGIN_HUMAN</code> (2).
 
The <code>origin</code> is either <code>TAG_ORIGIN_AUTOMATIC</code> (1) or <code>TAG_ORIGIN_HUMAN</code> (2).
 
It will return  
 
It will return  
[https://docs.python.org/3.8/library/constants.html?highlight=false#True True] if the tag was associated with the file, [https://docs.python.org/3.8/library/constants.html?highlight=false#False False] on failure.
+
[https://docs.python.org/3.10/library/constants.html?highlight=false#True True] if the tag was associated with the file, [https://docs.python.org/3.10/library/constants.html?highlight=false#False False] on failure.
  
==<code>start</code>==
+
==<code>type: int</code>==
When the event began in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
+
The type of message.
This corresponds to the <code>Start</code> column of the <code>Event</code> table.
+
It is one of the <code>[[Message Types|MESSAGE_TYPE]]</code> constants.
 
+
This corresponds to the <code>[MessageTypeID]</code> column of the <code>[Message]</code> table and should be a value from the <code>[ID]</code> column of the <code>[MessageType]</code> table.
==<code>title</code>==
 
This corresponds to the <code>Title</code> column of the <code>Event</code> table.
 
 
 
==<code>type</code>==
 
This corresponds to the <code>EventTypeID</code> column of the <code>Event</code> table.
 
It should contain a value from the <code>ID</code> column of the <code>EventType</code> table.
 
  
 
=Sample=
 
=Sample=
 +
<source lang="Python" highlight="3-7,9-10,19,31,36">
 +
def add_message(parent_truxton_file):
 +
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()
  
<syntaxhighlight lang="Python" highlight="32-38">
+
communication.addparticipant("703.555.1212", truxton.MESSAGE_PARTICIPANT_FROM, truxton.ENTITY_TYPE_PHONE_NUMBER)
import truxton
+
communication.addparticipant("202.555.1212", truxton.MESSAGE_PARTICIPANT_TO, truxton.ENTITY_TYPE_PHONE_NUMBER)
import shutil
 
 
 
from datetime import datetime
 
from calendar import timegm
 
from pathlib import Path
 
 
 
EPOCH_AS_FILETIME = 116444736000000000
 
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():
+
body1 = root_file.newchild()
  t = truxton.create()
+
body1.name = "Body.txt"
 +
body1.origin = truxton.ORIGIN_EMAIL_BODY
 +
body1.type = truxton.Type_ASCII_Text
 +
body1.write('Hello World')
 +
body1.save()
  
  create_event_type(t, EVENT_TYPE_FBI, "FBI Actions" )
+
if not communication.addpiece(body1, truxton.ORIGIN_EMAIL_BODY, 1):
 +
    print("Body not saved")
 +
else:
 +
    print("Body was saved")
  
  media = add_media(t)
+
attachment1 = root_file.newchild()
 +
attachment1.name = "Attachment.txt"
 +
attachment1.origin = truxton.ORIGIN_EMAIL_ATTACHMENT
 +
attachment1.type = truxton.Type_ASCII_Text
 +
attachment1.write('Goodbye World')
 +
attachment1.save()
  
  root_file = media.addroot()
+
if not communication.addpiece(attachment1, truxton.ORIGIN_EMAIL_ATTACHMENT, 1):
  root_file.save()
+
    print("Attachment not saved")
 +
else:
 +
    print("Attachment saved")
  
  add_ec(root_file)
+
communication.finished()
  
if __name__ == "__main__":
+
return None
  main()
+
</source>
</syntaxhighlight>
 

Latest revision as of 11:07, 16 April 2025

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

addnote(text: str) -> boolean

This adds an investigator's note. The text parameter is the contents of the note. It will return True if the tag was associated with the communication, False on failure. The note is stored in the [InvestigatorNote] table in the database.

addpiece(file: object, origin: int, instance: int) -> boolean

This allows you to add a file or child file as part of a communication. The origin parameter should be one of the defined constants.

addparticipant(account: str, name: str, role: int, artifact_type: int) -> str

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 name is the name of the person associated with this account or an empty string. The role parameter is the MESSAGE_PARTICIPANT constants. The artifact_type is used when the underlying function automatically adds the account to the artifacts table. It should be one of the defined constants. It should be a value that matches the [ID] column of the [MessageAddressType] table.

fileid: str

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

finished() -> boolean

This should be called after you have finished adding all of the pieces to this message. It will return True if the record was saved to the database, False if there was an error.

id: str

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

mediaid: str

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

received: datetime

When the message was received. This value can be set with either a datetime value or an integer representing FILETIME ticks. This corresponds to the [Received] column of the [Message] table.

save() -> boolean

This will commit the information to the [Message] table. It will return True if the record was saved to the database, False if there was an error.

sent: datetime

When the message was sent. This value can be set with either a datetime value or an integer representing FILETIME ticks. This corresponds to the [Sent] column of the [Message] table.

subject: str

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: str, reason: str, origin: int) -> boolean

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 is 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: int

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

def add_message(parent_truxton_file):
 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()

 communication.addparticipant("703.555.1212", truxton.MESSAGE_PARTICIPANT_FROM, truxton.ENTITY_TYPE_PHONE_NUMBER)
 communication.addparticipant("202.555.1212", truxton.MESSAGE_PARTICIPANT_TO, truxton.ENTITY_TYPE_PHONE_NUMBER)

 body1 = root_file.newchild()
 body1.name = "Body.txt"
 body1.origin = truxton.ORIGIN_EMAIL_BODY
 body1.type = truxton.Type_ASCII_Text
 body1.write('Hello World')
 body1.save()

 if not communication.addpiece(body1, truxton.ORIGIN_EMAIL_BODY, 1):
    print("Body not saved")
 else:
    print("Body was saved")

 attachment1 = root_file.newchild()
 attachment1.name = "Attachment.txt"
 attachment1.origin = truxton.ORIGIN_EMAIL_ATTACHMENT
 attachment1.type = truxton.Type_ASCII_Text
 attachment1.write('Goodbye World')
 attachment1.save()

 if not communication.addpiece(attachment1, truxton.ORIGIN_EMAIL_ATTACHMENT, 1):
    print("Attachment not saved")
 else:
    print("Attachment saved")

 communication.finished()

 return None