TruxtonCommunication

From truxwiki.com
Revision as of 14:11, 16 August 2021 by Sam (talk | contribs) (→‎Sample)
Jump to navigation Jump to search

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

addpiece(file, origin, instance)

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

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. It should be a value that matches the [ID] column of the [MessageAddressType] table.

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 [Message] table. It will return True if the record was saved to the database, False if there was an error.

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 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

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)
 communication.addparticipant("202.555.1212", truxton.MESSAGE_PARTICIPANT_TO)

 communication.finished()

 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()