<commit_before>import datetime

from bson import objectid

from vj4 import db
from vj4.util import argmethod

STATUS_READ = 1


@argmethod.wrap
async def add(sender_uid: int, sendee_uid: int, content: str):
  """Send a message from sender to sendee with specified content."""
  coll = db.Collection('message')
  await coll.insert({'sender_uid': sender_uid,
                     'sendee_uid': sendee_uid,
                     'content': content,
                     'status': 0,
                     'reply': []})


@argmethod.wrap
def get_multi(uid: int, *, fields=None):
  """Get messages related to a specified user."""
  coll = db.Collection('message')
  return coll.find({'$or': [{'sender_uid': uid}, {'sendee_uid': uid}]}, fields=fields)<commit_msg>move initial message content into reply<commit_after>import datetime

from bson import objectid

from vj4 import db
from vj4.util import argmethod

STATUS_READ = 1


@argmethod.wrap
async def add(sender_uid: int, sendee_uid: int, content: str):
  """Send a message from sender to sendee with specified content."""
  coll = db.Collection('message')
  await coll.insert({'sender_uid': sender_uid,
                     'sendee_uid': sendee_uid,
                     'status': 0,
                     'reply': [{'sender_uid': sender_uid,
                                'content': content,
                                'status': 0,
                                'at': datetime.datetime.utcnow()}]})


@argmethod.wrap
def get_multi(uid: int, *, fields=None):
  """Get messages related to a specified user."""
  coll = db.Collection('message')
  return coll.find({'$or': [{'sender_uid': uid}, {'sendee_uid': uid}]}, fields=fields)
{'fraction_non_alphanumeric': 0.13004750593824227, 'fraction_numerical': 0.005344418052256532, 'mean_word_length': 2.6951754385964914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6499190', 'n_tokens_mistral': 500, 'n_tokens_neox': 484, 'n_words': 146}