xxxxxxxxxx
const ratings = asyncHandler(async (req, res) => {
const { _id } = req.user
const { star, prodId } = req.body;
try {
const product = await Product.findById(prodId);
let alreadyRated = product.ratings.find((userId) => userId.postedby.toString() === _id.toString())
if (alreadyRated) {
const updateRating = await Product.updateOne({
ratings: { $elemMatch: alreadyRated },
}, {
$set: { "ratings.$.star": star }
}, {
new: true,
})
} else {
const rateProduct = await Product.findByIdAndUpdate(prodId, {
$push: {
ratings: {
star: star,
postedby: _id,
},
},
}, {
new: true,
})
}
const getallratings = await Product.findById(prodId);
let totalRatings = getallratings.ratings.length;
let sumRatings = getallratings.ratings
.filter((item) => typeof item.star === 'number')
.map((item) => item.star)
.reduce((prev, current) => prev + current, 0);
let actualRatings = Math.round(sumRatings / totalRatings);
let finalproduct = await Product.findByIdAndUpdate(prodId, {
totalrating: actualRatings
}, { new: true });
res.json(finalproduct);
} catch (error) {
throw new Error(error);
}
})
xxxxxxxxxx
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<config-file parent="com.apple.developer.associated-domains" target="*-Debug.plist">
<array>
<string>applinks:dianzishu.app</string>
</array>
</config-file>
<config-file parent="com.apple.developer.associated-domains" target="*-Release.plist">
<array>
<string>applinks:dianzishu.app</string>
</array>
</config-file>
<config-file parent="GADApplicationIdentifier" target="*-Info.plist">
<string>***ca-app-pub-3187198988135366~3590221682***</string>
</config-file>
<config-file parent="GADIsAdManagerApp" target="*-Info.plist">
<true />
</config-file>
messenger in website
xxxxxxxxxx
<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
xfbml : true,
version : 'v9.0'
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- Your Chat Plugin code -->
<div class="fb-customerchat"
attribution="setup_tool"
page_id="00000000000">
</div>
xxxxxxxxxx
# RenameUnpickler
import io
import pickle
class RenameUnpickler(pickle.Unpickler):
def find_class(self, module, name):
renamed_module = module
if module == "tools":
renamed_module = "whyteboard.tools"
return super(RenameUnpickler, self).find_class(renamed_module, name)
def renamed_load(file_obj):
return RenameUnpickler(file_obj).load()
def renamed_loads(pickled_bytes):
file_obj = io.BytesIO(pickled_bytes)
return renamed_load(file_obj)