コード例 #1
0
ファイル: mail.py プロジェクト: imjerry1994/web_bbs
def add():
    """发送新私信"""
    form = request.form.to_dict()
    u = current_user()
    receiver_id = form.get('receiver_id', None)

    if receiver_id is None:
        r_name = form.get('receiver_name', None)
        receiver = User.one(username=r_name)
    else:
        # receiver = User.one(id=receiver_id)
        receiver = cached_user_id2user(receiver_id)
    if receiver is None:
        flash('收件人不存在')
    elif receiver.id == u.id or receiver.username == u.username:
        flash('私信是发给其他人的哦,请重新输入收件人')
    else:
        Messages.send(
            title=form['title'],
            content=form['content'],
            sender_id=u.id,
            receiver_id=receiver.id,
        )
        flash('发送成功')
        with data_cache.pipeline(transaction=False) as pipe:
            key = 'user_id_{}.sent_message'.format(u.id)
            key2 = 'user_id_{}.received_message'.format(receiver_id)
            pipe.delete(key)
            pipe.delete(key2)
            pipe.execute()
    return redirect(url_for('.index'))
コード例 #2
0
def send_mails(sender, receivers, reply_link, reply_content):
    content = '链接:{}\n内容:{}'.format(reply_link, reply_content)
    for r in receivers:
        title = '你被 {} AT 了'.format(sender.username)
        Messages.send(title=title,
                      content=content,
                      sender_id=sender.id,
                      receiver_id=r.id)
コード例 #3
0
def add():
    form = request.form.to_dict()
    u = current_user()
    receiver_id = int(form['receiver_id'])
    Messages.send(title=form['title'],
                  content=form['content'],
                  sender_id=u.id,
                  receiver_id=receiver_id)

    return redirect(url_for('.index'))
コード例 #4
0
ファイル: topic.py プロジェクト: Jimyfar/bbs
def send_like_me(sender, receiver, topic_link, topic_title):
    print('send_reply_me', sender, receiver, topic_title)
    content = topic_link

    title = '{} 点赞了你的 {}'.format(sender.username, topic_title)
    Messages.send(
        title=title,
        content=content,
        sender_id=sender.id,
        receiver_id=receiver.id,
        type='like_me',
    )
コード例 #5
0
def send_at_me(sender, receivers, reply_link, reply_content):
    print('send_at_me', sender, receivers, reply_content)
    content = '链接:{}\n内容:{}'.format(reply_link, reply_content)
    for r in receivers:
        title = '你被 {} AT 了'.format(sender.username)
        Messages.send(
            title=title,
            content=content,
            sender_id=sender.id,
            receiver_id=r.id,
            type='at_me',
        )
コード例 #6
0
def send_reply_me(sender, receiver, reply_link, replied_topic_title):
    print('send_reply_me', sender, receiver, replied_topic_title)
    content = reply_link

    title = '{} 回复了你 {}'.format(sender.username, replied_topic_title)
    Messages.send(
        title=title,
        content=content,
        sender_id=sender.id,
        receiver_id=receiver.id,
        type='reply_me',
    )
コード例 #7
0
def add():
    form = request.form.to_dict()
    u = current_user()
    receiver_username = form['receiver_username']
    r = User.one(username=receiver_username)
    receiver_id = r.id
    Messages.send(title=form['title'],
                  content=form['content'],
                  sender_id=u.id,
                  receiver_id=receiver_id)

    return redirect(url_for('.index'))
コード例 #8
0
def reset_send_mail():
    username = request.form['username']
    u = User.one(username=username)
    if u is None:
        flash('该用户不存在!')
        return redirect(url_for('index.index'))
    token = new_csrf_token(u)
    Messages.send(
        title='sc论坛重置密码',
        content='http://152.136.129.239/reset/view?token={}'.format(token),
        sender_id=0,
        receiver_id=u.id)
    flash('邮件发送成功!')
    return redirect(url_for('index.index'))
コード例 #9
0
def reset_send():
    form = request.form.to_dict()
    username = form['username']
    u = User.one(username=username)
    token = str(uuid.uuid4())
    cache.set(token, u.id)
    # csrf_tokens[token] = u.id

    link = 'https://www.fengfan620.com/reset/view?token={}'.format(token)
    Messages.send(title='小破站重置密码',
                  content='点击链接重置密码啦~~点击<br>{}'.format(link),
                  sender_id=1,
                  receiver_id=u.id)
    return redirect(url_for('index.index'))
コード例 #10
0
def add():
    form = request.form.to_dict()
    u = current_user()
    receiver = User.one(username=form['receiver'])
    if receiver is not None:
        # 发邮件
        receiver_id = receiver.id
        title = '{}'.format(form['title'])
        Messages.send(title=title,
                      content=form['content'],
                      sender_id=u.id,
                      receiver_id=receiver_id)
        return redirect(url_for('.index'))
    else:
        return redirect(url_for('.index'))
コード例 #11
0
def reset():
    form = request.form
    user = form['username']
    u = User.one(username=user)
    token = int(uuid.uuid4())
    csrf_tokens[token] = u.id
    print(csrf_tokens)
    # key = 'token_{}'.format(token)
    # cache.set(key, u.id)
    Messages.send(
        title='重置密码',
        content='http://localhost:3000/reset/view?token={}'.format(token),
        sender_id=u.id,
        receiver_id=u.id,
    )
    return render_template('index_1.html')
コード例 #12
0
def reset():
    """
    找回密码
    """
    username = request.form['username']
    u = User.one(username=username)

    token = str(uuid.uuid4())
    cache.set(token, u.id, ex=3600)

    content = '{}/reset/view?token={}'.format(secret.dns, token)
    Messages.send(title='找回密码',
                  content=content,
                  sender_id=u.id,
                  receiver_id=u.id)

    return redirect(url_for('.index'))
コード例 #13
0
ファイル: reset.py プロジェクト: dinkdinkdink/bbs_server
def send():
    form = request.form.to_dict()
    username = form['username']
    user = User.one(username=username)
    # 发邮件
    token = str(uuid.uuid4())
    # 修改token写入方式
    csrf_tokens.set(token, user.id)
    Messages.send(
        title='修改密码地址',
        content='http://49.235.39.104:80/reset/view?token={}&user={}'.format(
            token, user.username),
        sender_id=user.id,
        receiver_id=user.id,
    )
    # 发送完毕回到登录界面
    return redirect(url_for('index.index'))
コード例 #14
0
ファイル: index.py プロジェクト: Corgist/flask_bbs
def send():
    form = request.form.to_dict()
    username = form['username']
    u = User.one(username=username)
    if u is not None:
        token = str(uuid.uuid4())
        cache.set(token, u.id)
        cache.expire(token, 1800)
        title = '来自 {} 的密码找回信件'.format(u.username)
        content = 'http://www.corgist.xyz/reset/view?token={}'.format(token)
        Messages.send(title=title,
                      content=content,
                      sender_id=1,
                      receiver_id=u.id)
    else:
        abort(404)
    return redirect(url_for('.index'))
コード例 #15
0
ファイル: reset.py プロジェクト: yivocs/flask-bbs
def send_mail():
    form = request.form.to_dict()
    username = form.get('username')
    u = User.one(username=username)
    email = form.get('email')

    if email == u.email:
        token = str(uuid.uuid4())

        cache.set(token, u.id)
        Messages.send(
            title='reset password',
            content='https://yivocs.cn/reset/view?token={}'.format(token),
            sender_id=u.id,
            receiver_id=u.id)
        return redirect(url_for('index.index'))
    else:
        return redirect('404')
コード例 #16
0
ファイル: index.py プロジェクト: lilunqin/llqClub
def send():
    username = request.args['user_name']
    u = User.one(username=username)
    form = dict(
        user_id=u.id,
        token=str(uuid.uuid4()),
    )
    token = Token.new(form)
    log('dsafsdf', token)
    token.save()
    Messages.send(
        title='重置密码邮件',
        # production
        content='http://49.233.80.207/reset/view?token={}'.format(token.token),
        # debug
        # content='http://localhost:3000/reset/view?token={}'.format(token.token),
        sender_id=current_user().id,
        receiver_id=u.id,
    )
    return redirect('/')
コード例 #17
0
ファイル: reset.py プロジェクト: WoodDown/Club
def send():
    form = request.form
    username = form['username']
    token = str(uuid.uuid4())

    u = User.one(username=username)
    reset_tokens[token] = u.id

    if u is not None:
        # 发邮件
        ip = config.ip
        Messages.send(
            title='重置论坛密码',
            content='点击链接重置论坛密码:\nhttp://{}/reset/view?token={}'.format(ip, token),
            # content='点击链接重置论坛密码:\nhttp://localhost:3000/reset/view?token={}'.format(token),
            sender_id=u.id,
            receiver_id=u.id
        )

        log('user reset', username, token, u.id)

    return redirect(url_for("index.index"))
コード例 #18
0
ファイル: reset.py プロジェクト: maixianyu/flask_zhihu
def generate_fake_date(app):
    # 写入用户 maixy
    form = dict(
        username='******',
        password='******',
        email=config.test_mail,
    )
    u_1 = User.register(form)

    # 写入用户 maixianyu
    form = dict(
        username='******',
        password='******',
        email=config.test_mail,
    )
    u_2 = User.register(form)

    # 写入用户 xiandan
    form = dict(
        username='******',
        password='******',
        email=config.test_mail,
    )
    u_3 = User.register(form)

    # 话题模版
    question_form = dict(
        author=u_1.username,
        title='如何看待x事件?',
        content='3天前发生了这件事,你怎么看?',
        count_answer=1,
    )

    # 回答模版
    with open('answer_demo.md', encoding='utf8') as f:
        content = f.read()
        answer_form = dict(
            author=u_1.username,
            question_id=1,
            content=content,
            agree=1,
            disagree=1,
        )

    comment_form = dict(
        author=u_1.username,
        content="说得好。",
        answer_id=0,
    )

    with app.test_request_context():
        for i in range(10):
            print('begin question <{}>'.format(i))
            Question.new(question_form)

            # 每个问题两个回答
            print('begin answer <{}>'.format(i))
            answer_form['question_id'] = i + 1
            Answer.manual_new(answer_form)

            print('begin answer <{}>'.format(i))
            answer_form['question_id'] = i + 1
            Answer.manual_new(answer_form)

        for i in range(20):
            print('begin AnswerComment <{}>'.format(i))
            comment_form['author'] = u_2.username
            comment_form['answer_id'] = i + 1
            AnswerComment.manual_new(comment_form)

            print('begin AnswerComment <{}>'.format(i))
            comment_form['author'] = u_3.username
            comment_form['answer_id'] = i + 1
            comment_form['content'] = "同意楼上。"
            AnswerComment.manual_new(comment_form)

    title = '一个请教'
    content = '我的看法是xx。'
    sender_id = u_1.id
    receiver_id = u_2.id
    Messages.send(title, content, sender_id, receiver_id)