timApp.messaging.timMessage package#

Submodules#

timApp.messaging.timMessage.internalmessage_models module#

class timApp.messaging.timMessage.internalmessage_models.DisplayType(value)[source]#

Bases: enum.Enum

An enumeration.

STICKY = 2#
TOP_OF_PAGE = 1#
class timApp.messaging.timMessage.internalmessage_models.InternalMessage(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

A TIM message.

block#
can_mark_as_read#

Whether the recipient can mark the message as read.

display_type#

How the message is displayed.

displays#
doc_id#

Block identifier.

expires#

“When the message display will disappear.

id#

Message identifier.

par_id#

Paragraph identifier.

readreceipts: list['InternalMessageReadReceipt']#
replies_to#

Id of the message which this messages is a reply to

reply#

Whether the message can be replied to.

to_json() dict[str, Any][source]#
class timApp.messaging.timMessage.internalmessage_models.InternalMessageDisplay(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

Where and for whom a TIM message is displayed.

display_block#
display_doc_id#

Identifier for the document or the folder where the message is displayed. If null, the message is displayed globally.

id#

Message display identifier.

message#
message_id#

Message identifier.

to_json() dict[str, Any][source]#
usergroup#
usergroup_id#

Who sees the message; if null, displayed for everyone.

class timApp.messaging.timMessage.internalmessage_models.InternalMessageReadReceipt(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

Metadata about read receipts.

static get_for_user(user: User, message: timApp.messaging.timMessage.internalmessage_models.InternalMessage) Optional[InternalMessageReadReceipt][source]#
last_seen#

Timestamp for the last time the the message was displayed to the user

marked_as_read_on#

Timestamp for when the message was marked as read.

message#
message_id#

Message identifier.

to_json() dict[str, Any][source]#
user#
user_id#

Identifier for the user who marked the message as read.

timApp.messaging.timMessage.routes module#

class timApp.messaging.timMessage.routes.MessageBody(messageBody: str, messageSubject: str, recipients: list[str] | None = None)[source]#

Bases: object

messageBody: str#
messageSubject: str#
recipients: list[str] | None = None#
class timApp.messaging.timMessage.routes.MessageOptions(messageChannel: bool, important: bool, isPrivate: bool, archive: bool, pageList: str, readReceipt: bool, reply: bool, sender: str, senderEmail: str, repliesTo: int | None = None, expires: datetime.datetime | None = None)[source]#

Bases: object

archive: bool#
expires: datetime.datetime | None = None#
important: bool#
isPrivate: bool#
messageChannel: bool#
pageList: str#
readReceipt: bool#
repliesTo: int | None = None#
reply: bool#
sender: str#
senderEmail: str#
class timApp.messaging.timMessage.routes.ReadReceiptFormat(value)[source]#

Bases: enum.Enum

An enumeration.

CSV = 'csv'#
TableFormQuery = 'tableform-query'#
class timApp.messaging.timMessage.routes.ReplyOptions(archive: bool, messageChannel: bool, pageList: str, recipient: str, readReceipt: bool = True, repliesTo: int | None = None)[source]#

Bases: object

archive: bool#
messageChannel: bool#
pageList: str#
readReceipt: bool = True#
recipient: str#
repliesTo: int | None = None#
class timApp.messaging.timMessage.routes.TimMessageData(id: int, sender: str | None, doc_path: str, can_mark_as_read: bool, can_reply: bool, display_type: timApp.messaging.timMessage.internalmessage_models.DisplayType, message_body: str, message_subject: str)[source]#

Bases: object

can_mark_as_read: bool#
can_reply: bool#
display_type: timApp.messaging.timMessage.internalmessage_models.DisplayType#
doc_path: str#
id: int#
message_body: str#
message_subject: str#
sender: str | None#
class timApp.messaging.timMessage.routes.TimMessageReadReceipt(message_id: int, user_id: int, marked_as_read_on: datetime.datetime, can_mark_as_read: bool)[source]#

Bases: object

can_mark_as_read: bool#
marked_as_read_on: datetime.datetime#
message_id: int#
user_id: int#
timApp.messaging.timMessage.routes.cancel_read_receipt(message_id: int) flask.wrappers.Response[source]#

Removes read receipt date and the user who marked it from the database entry.

Parameters

message_id – Message identifier

Returns

timApp.messaging.timMessage.routes.check_messages_folder_path(msg_folder_path: str, tim_msg_folder_path: str) timApp.folder.folder.Folder[source]#
Checks if the /messages/tim-messages folder exists and if not, creates it. All users

get view access to /messages folder and edit access to /messages/tim-messages folder so that documents for sent messages can be created. Also creates the preamble for message documents.

Parameters
  • msg_folder_path – path for /messages

  • tim_msg_folder_path – path for /messages/tim-messages

Returns

/messages/tim-messages folder

timApp.messaging.timMessage.routes.check_urls(urls: str) flask.wrappers.Response[source]#

Checks if given URLS’s exist in TIM and that user has right to post TIM message to them

Parameters

urls – Urls where user wishes to post TIM message

Returns

Shortened urls to show the user in the UI, or an error message

timApp.messaging.timMessage.routes.create_message_displays(msg: timApp.messaging.timMessage.internalmessage_models.InternalMessage, pages: list[timApp.item.item.Item], recipients: list[timApp.user.usergroup.UserGroup]) None[source]#

Creates InternalMessageDisplay entries for all recipients and display pages.

Parameters
  • msg – Message

  • pages – List of pages where message is displayed

  • recipients – List of message recipients

Returns

timApp.messaging.timMessage.routes.create_tim_message(tim_message: timApp.messaging.timMessage.internalmessage_models.InternalMessage, options: timApp.messaging.timMessage.routes.MessageOptions, message_body: timApp.messaging.timMessage.routes.MessageBody, message_viewers: Optional[list[timApp.user.usergroup.UserGroup]] = None) timApp.document.docinfo.DocInfo[source]#

Creates a TIM document for the message to the TIM messages folder at TIM’s root.

Parameters
  • tim_message – InternalMessage object

  • options – Options related to the message

  • message_body – Message subject, contents and list of recipients

  • message_viewers – Groups that are allowed to view the message. If None, all recepients can.

Returns

The created Document object

timApp.messaging.timMessage.routes.expire_tim_message(message_doc_id: int) flask.wrappers.Response[source]#

Expire a TIM message.

Parameters

message_doc_id – Document ID of the message to expire.

Returns

OK response if message was successfully expired.

timApp.messaging.timMessage.routes.get_display_pages(pagelist: list[str]) list[timApp.item.item.Item][source]#

Finds folders and documents based on their paths.

Parameters

pagelist – list of paths

Returns

list of folders and documents

timApp.messaging.timMessage.routes.get_global_messages() flask.wrappers.Response[source]#

Retrieve global messages return them in json format.

Returns

List of TIM messages to display

timApp.messaging.timMessage.routes.get_read_receipt(doc_id: int) flask.wrappers.Response[source]#

Retrieve read receipt object for the current user and message related to the given document id

Parameters

doc_id – Id of the message document

Returns

timApp.messaging.timMessage.routes.get_read_receipts(message_doc: int, include_read: bool = False, include_unread: bool = False, separator: str = ';', receipt_format: timApp.messaging.timMessage.routes.ReadReceiptFormat = Field(name='receipt_format', type=<enum 'ReadReceiptFormat'>, default=<ReadReceiptFormat.CSV: 'csv'>, default_factory=<dataclasses._MISSING_TYPE object>, init=True, repr=True, hash=None, compare=True, metadata=mappingproxy({'by_value': True}), kw_only=False, _field_type=_FIELD)) flask.wrappers.Response[source]#
timApp.messaging.timMessage.routes.get_recipient_users(recipients: list[str] | None) list[timApp.user.usergroup.UserGroup][source]#

Finds UserGroup objects of recipients based on their email

Parameters

recipients – list of recipients’ emails

Returns

list of recipient UserGroups

timApp.messaging.timMessage.routes.get_tim_messages(item_id: int) flask.wrappers.Response[source]#

Retrieve messages displayed for current based on item id and return them in json format.

Parameters

item_id – Identifier for document or folder where message is displayed

Returns

List of TIM messages to display

timApp.messaging.timMessage.routes.get_tim_messages_as_list(item_id: Optional[int] = None) list[timApp.messaging.timMessage.routes.TimMessageData][source]#

Retrieve messages displayed for current user based on item id and return them as a list.

Parameters

item_id – Identifier for document or folder where message is displayed. If None, global messages are returned.

Returns

List of TIM messages to display

timApp.messaging.timMessage.routes.mark_as_read(message_id: int) flask.wrappers.Response[source]#

Marks given message as read in database. Expects that message receiver and marker are the same person.

Parameters

message_id – Id of given message

Returns

timApp.messaging.timMessage.routes.reply_to_tim_message(options: timApp.messaging.timMessage.routes.ReplyOptions, message: timApp.messaging.timMessage.routes.MessageBody) flask.wrappers.Response[source]#
timApp.messaging.timMessage.routes.send_message_or_reply(message: timApp.messaging.timMessage.routes.MessageBody, options: timApp.messaging.timMessage.routes.MessageOptions) flask.wrappers.Response[source]#

Creates a new TIM message and saves it to database.

Parameters
  • options – Options related to the message

  • message – Message subject, contents and sender

Returns

timApp.messaging.timMessage.routes.send_tim_message(message: timApp.messaging.timMessage.routes.MessageBody, options: timApp.messaging.timMessage.routes.MessageOptions) flask.wrappers.Response[source]#
timApp.messaging.timMessage.routes.update_tim_msg_doc_settings(message_doc: timApp.document.docinfo.DocInfo, sender: timApp.user.user.User | None, message_body: timApp.messaging.timMessage.routes.MessageBody) None[source]#

Sets the message information into the preamble macros.

Parameters
  • message_doc – TIM message document

  • sender – Sender user

  • message_body – Message body

Returns

Module contents#