Adjusted parameters for /v1/people response. Check for empty post content. Re-enable support for WWP

This commit is contained in:
Jemma Poffinbarger
2023-04-06 01:16:22 -05:00
parent 1d64d7621f
commit 32ea68b549
3 changed files with 8 additions and 4 deletions

View File

@@ -13,7 +13,9 @@ router.get('/', async function (req, res) {
let query = {
removed: false,
is_spoiler: 0,
app_data: { $eq: null },
parent: { $eq: null },
message_to_pid: { $eq: null }
}

View File

@@ -163,9 +163,11 @@ async function newPost(req, res) {
}
let body = req.body.body;
if(body)
body = req.body.body.replace(/[^A-Za-z\d\s-_!@#$%^&*(){}‛¨ƒºª«»“”„¿¡←→↑↓√§¶†‡¦–—⇒⇔¤¢€£¥™©®+×÷=±∞ˇ˘˙¸˛˜′″µ°¹²³♭♪•…¬¯‰¼½¾♡♥●◆■▲▼☆★♀♂,./?;:'"\\<>]/g, "");
body = req.body.body.replace(/[^A-Za-z\d\s-_!@#$%^&*(){}‛¨ƒºª«»“”„¿¡←→↑↓√§¶†‡¦–—⇒⇔¤¢€£¥™©®+×÷=±∞ˇ˘˙¸˛˜′″µ°¹²³♭♪•…¬¯‰¼½¾♡♥●◆■▲▼☆★♀♂,./?;:'"\\<>]/g, "").trim();
if(body && body.length > 280)
body = body.substring(0,280);
if(!body && !painting && !screenshot)
return res.sendStatus(400);
const document = {
title_id: paramPackData.title_id,
community_id: community.app_id ? community.app_id : community.community_id,

View File

@@ -154,7 +154,7 @@ class XmlResponseGenerator {
for (const post of posts) {
xml = xml.e("person")
.e("posts")
postObj(xml, post, { with_mii: true });
postObj(xml, post, { with_mii: true, app_data: false });
xml = xml.up().up();
}
xml = xml.up().up()
@@ -217,10 +217,10 @@ class XmlResponseGenerator {
*/
function postObj(xml, post, options) {
xml = xml.e("post");
if (post.app_data) {
if (post.app_data && options.app_data) {
xml.e("app_data", post.app_data.replace(/[^A-Za-z0-9+/=]/g, "").replace(/[\n\r]+/gm, '').trim()).up();
}
xml.e("body", post.body ? post.body.replace(/[^A-Za-z\d\s-_!@#$%^&*(){}+=,.<>/?;:'"\[\]]/g, "") : "").up()
xml.e("body", post.body ? post.body.replace(/[^A-Za-z\d\s-_!@#$%^&*(){}+=,.<>/?;:'"\[\]]/g, "").replace(/[\n\r]+/gm, '') : "").up()
.e("community_id", post.community_id).up()
.e("country_id", post.country_id ? post.country_id : 254).up()
.e("created_at", new moment(post.created_at).format('YYYY-MM-DD HH:MM:SS')).up()