chat.models.message

Classes

MessageFile

A general file (image, document, pdf, etc), referenced in the database.

Message

A single chat message bound to channel.

Functions

init(→ None)

Ensures that the message id is created upon instantiation. This helps

Module Contents

class chat.models.message.MessageFile[source]

Bases: onegov.file.File

A general file (image, document, pdf, etc), referenced in the database.

Thanks to the use of Depot files can be seemingly stored in the database (with transaction guarantees), without actually storing it in the database.

__mapper_args__[source]
class chat.models.message.Message[source]

Bases: onegov.core.orm.Base

A single chat message bound to channel.

__mapper_args__[source]
__tablename__ = 'messages'[source]
id: Column[str][source]
channel_id: Column[str][source]
owner: Column[str | None][source]
type: Column[str | None][source]
meta: Column[dict[str, Any]][source]
text: Column[str | None][source]
created: Column[datetime][source]
modified: Column[datetime | None][source]
file[source]
__hash__() int[source]

Return hash(self).

__eq__(other: object) bool[source]

Return self==value.

property subtype: str | None[source]

An optional subtype for this message used for separating messages of a type further (currently for UI).

Should be made unique, but there’s no guarantee.

get(request: onegov.core.request.CoreRequest) str | None[source]

Code rendering a message should call this method to get the actual text of the message. It might be rendered from meta or it might be returned directly from the text column.

How this is done is up to the polymorphic Message.

classmethod bound_messages(session: sqlalchemy.orm.Session) MessageCollection[Self][source]

A message collection bound to the polymorphic identity of this message.

chat.models.message.init(target: Message, args: tuple[Any, Ellipsis], kwargs: dict[str, Any]) None[source]

Ensures that the message id is created upon instantiation. This helps to ensure that each message is ordered according to it’s creation.

Note that messages created within a millisecond of each other are ordered randomly.