File: post.py

package info (click to toggle)
python-exchangelib 5.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,084 kB
  • sloc: python: 25,351; sh: 6; makefile: 5
file content (38 lines) | stat: -rw-r--r-- 1,405 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import logging

from ..fields import BodyField, DateTimeField, MailboxField, TextField
from .item import Item
from .message import Message

log = logging.getLogger(__name__)


class PostItem(Item):
    """MSDN: https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/postitem"""

    ELEMENT_NAME = "PostItem"

    conversation_index = Message.FIELDS["conversation_index"]
    conversation_topic = Message.FIELDS["conversation_topic"]

    author = Message.FIELDS["author"]
    message_id = Message.FIELDS["message_id"]
    is_read = Message.FIELDS["is_read"]

    posted_time = DateTimeField(field_uri="postitem:PostedTime", is_read_only=True)
    references = TextField(field_uri="message:References")
    sender = MailboxField(field_uri="message:Sender", is_read_only=True, is_read_only_after_send=True)


class PostReplyItem(Item):
    """MSDN: https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/postreplyitem"""

    ELEMENT_NAME = "PostReplyItem"

    # This element only has Item fields up to, and including, 'culture'
    # TDO: Plus all message fields
    new_body = BodyField(field_uri="NewBodyContent")  # Accepts and returns Body or HTMLBody instances

    culture_idx = Item.FIELDS.index_by_name("culture")
    sender_idx = Message.FIELDS.index_by_name("sender")
    FIELDS = Item.FIELDS[: culture_idx + 1] + Message.FIELDS[sender_idx:]