微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

云代码功能将验证的电子邮件重置为假

如何解决云代码功能将验证的电子邮件重置为假

我想要实现的是,

  1. 我有带有 to(Pointer to User) 和 from(Pointer 给用户)。

  2. 我有跟随表用户(指向用户的指针)和 跟随(指向用户的指针)。

  3. 具有关注者计数和关注计数的用户

我正在尝试向关注表添加行 使用代码并正确添加但在执行之前保存它 发送验证电子邮件以使用并将电子邮件验证设置为 false。

Parse.Cloud.beforeSave("Follow",async (request) => {
    const status = request.object.get("status");
    var followsname = "";
    var _username = "";
    if (!request.original) {
        if (status == "following") {
            const following = new Parse.Query(Parse.User);
            following.get(request.object.get("user").id)
                .then(function (user) {
                    const jsondata = JSON.stringify(user);
                    const userjson = JSON.parse(jsondata);
                    user.increment("following");
                    _username = userjson.username;
                    console.log(_username);
                    user.save(null,{ useMasterKey: true });
                })
                .catch(function (error) {
                    console.error("Got an error in following" + error.code + " : " + error.message);
                });
            const follower = new Parse.Query(Parse.User);
            await follower.get(request.object.get("follows").id)
                .then(function (user) {
                    const jsondata = JSON.stringify(user);
                    const userjson = JSON.parse(jsondata);
                    user.increment("followers");
                    followsname = userjson.username;
                    //return was here
                    user.save(null,{ useMasterKey: true });
                })
                .catch(function (error) {
                    console.error("Got an error in follows save" + error.code + " : " + error.message);
                });
            const notification = new Parse.Object("Notification");
            notification.set("from",request.object.get("user"));
            notification.set("to",request.object.get("follows"));
            notification.set("type","following");
            notification.set("priority",1);
            notification.set("read",false);
            notification.set("data",_username + " started following you.");
            try {
                const result = await notification.save(null,{ useMasterKey: true });
                console.log('Notification created',result);
                request.object.set("notification",notification);
            } catch (error) {
                console.error('Error while creating Notification: ',error);
            }


        } else if (status == "requested") {
            const follower = new Parse.Query(Parse.User);
            await follower.get(request.object.get("user").id)
                .then(function (user) {
                    const jsondata = JSON.stringify(user);
                    const userjson = JSON.parse(jsondata);
                    _username = userjson.username;
                    //return was here
                })
                .catch(function (error) {
                    console.error("Got an error in follows save" + error.code + " : " + error.message);
                });
            const notification = new Parse.Object("Notification");
            notification.set("from","request");
            notification.set("priority",_username + " has requested to following you.");

            try {
                const result = await notification.save(null,{ useMasterKey: true });
                // Access the Parse Object attributes using the .GET method
                console.log('Notification created',error);
            }

        }
    } else {
        if (request.original.get("status") == "requested" && request.object.get("status") == "following") {
            const following = new Parse.Query(Parse.User);
            following.get(request.object.get("user").id)
                .then(function (user) {
                    user.increment("following");
                    //return was here
                    user.save();
                })
                .catch(function (error) {
                    console.error("Got an error " + error.code + " : " + error.message);
                });
            const follower = new Parse.Query(Parse.User);
            follower.get(request.object.get("follows").id)
                .then(function (user) {
                    user.increment("followers");
                    //return was here
                    user.save();
                })
                .catch(function (error) {
                    console.error("Got an error " + error.code + " : " + error.message);
                });
            const notification_user = new Parse.Object("Notification");
            notification_user.set("to",request.object.get("user"));
            notification_user.set("from",request.object.get("follows"));
            notification_user.set("type","request");
            notification_user.set("priority",1);
            notification_user.set("read",false);
            notification_user.set("data",request.object.get("follows").username + " has accepted following request.");
            try {
                const result = await notification_user.save(null,result);

            } catch (error) {
                console.error('Error while creating Notification: ',error);
            }
            const notification_follower = new Parse.Object("Notification");
            notification_follower.set("from",request.object.get("user"));
            notification_follower.set("to",request.object.get("follows"));
            notification_follower.set("type","request");
            notification_follower.set("priority",1);
            notification_follower.set("read",false);
            notification_follower.set("data",request.object.get("user").username + " has started following you.");
            try {
                const result = await notification_follower.save(null,error);
            }
        }
    }
}
);

然后当我保存这个时,我尝试创建通知并分别增加关注者和关注者计数 使用下面的云代码功能

问题:每次我尝试添加行关注表时,都会关注“jathin”用户在这种情况下,他会收到验证邮件 并且他的已验证电子邮件设置为 false

我是解析来自 Firebase 的即时消息的新手,请帮忙。

{{1}}

我拯救粉丝的方法错了吗? 我做错了什么

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。