Ejemplo n.º 1
0
 def new(cls, conversation, user_id):
     record = cls(None, user_id, conversation.get_user_conversation_acl())
     record['user'] = Reference(RecordID('user', user_id))
     record['conversation'] = Reference(conversation.id)
     record['unread_count'] = 0
     record['is_admin'] = False
     return record
Ejemplo n.º 2
0
 def new(cls, user_id: str, message_id: str):
     if not isinstance(user_id, str):
         raise ValueError('user_id is not str')
     if not isinstance(message_id, str):
         raise ValueError('message_id is not str')
     return cls(RecordID(cls.record_type,
                         Receipt.consistent_id(user_id, message_id)),
                user_id,
                None,
                data={
                    'user': Reference(RecordID('user', user_id)),
                    'message': Reference(RecordID('message', message_id))
                })
Ejemplo n.º 3
0
 def __init__(self, user_id: str, message_id: str):
     if not isinstance(user_id, str):
         raise ValueError('user_id is not str')
     if not isinstance(message_id, str):
         raise ValueError('message_id is not str')
     self.record = Record(
         RecordID('receipt', Receipt.consistent_id(user_id, message_id)),
         user_id,
         None,
         data={
             'user_id': Reference(RecordID('user', user_id)),
             'message_id': Reference(RecordID('message', message_id))
         }
     )
Ejemplo n.º 4
0
 def test_reference(self):
     value = {
         "$type": "ref",
         "$id": "note/c1d0e8d4-648c-4c88-86c6-22feb1a6e734"
     }
     assert deserialize_value(value) == \
         Reference(RecordID("note", "c1d0e8d4-648c-4c88-86c6-22feb1a6e734"))
Ejemplo n.º 5
0
 def __init__(self, message):
     super().__init__(RecordID(self.record_type, str(uuid.uuid4())),
                      current_user_id(), message.acl)
     for key in [
             'attachment', 'body', 'metadata', 'conversation',
             'message_status', 'edited_by', 'edited_at'
     ]:
         if key in message:
             self[key] = message.get(key, None)
     self['parent'] = Reference(message.id)