Exemple #1
0
def create_msg(rq_raw, u):
    ''' create msg from user form '''
    rq = check_check(rq_raw)
    date = str(gts())
    txt = rq.txt
    if rq.pic:
        for n in rq.pic.split():
            txt += '\n\n@image: %s' % n
    o = mydict(txt=txt,
               title=rq.title,
               date=date,
               ea=rq.ea,
               who=u.uname,
               addr=u.uaddr,
               to=rq.to)
    if rq.repto:
        o.repto = rq.repto
    if rq.tags and not rq.topicid:
        o.tags = mk_tags(rq.tags)
    blob = fo.obj_to_file(o, 60).encode('utf-8')
    msgid = hsh(blob)
    o.topicid = rq.topicid or msgid
    o = msghook.hook(o, True)
    blob = fo.obj_to_file(o).encode('utf-8')
    write_msg(o, msgid, blob, date, True)
    return msgid
Exemple #2
0
def toss(msgfrom, addr, tmsg):
    lines = b64d(tmsg).decode('utf-8').splitlines()
    if flt.echo_flt(lines[0]):
        mo = sx.mydict(date=sx.gts(),
                       msgfrom=msgfrom,
                       addr=addr,
                       echoarea=lines[0],
                       msgto=lines[1],
                       subj=lines[2],
                       msg='\n'.join(lines[4:]))
        return mo
Exemple #3
0
def file_to_obj(s):
    ''' transform ii msg to object '''
    pz = s.splitlines()
    o = sx.mydict()
    optz = pz[0].split('/')
    o.update(dict(zip(optz[::2], optz[1::2])))
    for i, n in enumerate(('ea', 'date', 'who', 'addr', 'to', 'title')):
        o[n] = pz[i + 1]
    o.txt = '\n'.join(pz[8:])
    o.date = int(o.date) if o.date else sx.gts()
    return o
Exemple #4
0
def _parze(msg):
    pz = msg.splitlines()
    mo = sx.mydict()
    optz = pz[0].split('/')
    mo.update(dict(zip(optz[::2], optz[1::2])))
    for i, n in enumerate(
        ('echoarea', 'date', 'msgfrom', 'addr', 'msgto', 'subj')):
        mo[n] = pz[i + 1]
    mo.msg = '\n'.join(pz[8:])
    mo.date = int(mo.date) if mo.date else sx.gts()
    return mo
Exemple #5
0
def accept_msg(rq_raw):
    ''' accept msg from fetcher '''
    rq = check_check(rq_raw)
    if rq:
        date = str(gts())
        msgid = rq.msgid
        if not msg_flt(msgid):
            return
        o = rq
        blob = fo.obj_to_file(o).encode('utf-8')
        write_msg(o, msgid, blob, date, True)
        return msgid
Exemple #6
0
def point_newmsg(tags):
    mo = sx.mydict(date=sx.gts())
    mo.update(**tags)
    if _filter_msg_call(tags): return mkmsg(mo)
Exemple #7
0
def toss(msgfrom,addr,tmsg):
    lines = b64d(tmsg).decode('utf-8').splitlines()
    if flt.echo_flt(lines[0]):
        mo = sx.mydict(date=sx.gts(),msgfrom=msgfrom,addr=addr,echoarea=lines[0],msgto=lines[1],subj=lines[2],msg='\n'.join(lines[4:]))
        return mo
Exemple #8
0
def point_newmsg(tags):
    mo = sx.mydict(date=sx.gts())
    mo.update(**tags)
    if _filter_msg_call(tags): return mkmsg(mo)