feat: mask Iranian phone numbers in user-generated text fields

کاربران نتونن با گذاشتن شماره موبایل/تلفن توی بیو، کپشن پست/ریلز، توضیحاتِ
فروشگاه/کالا/پروژه/دوره/پروفایلِ آموزشگاه، بیرون از پلتفرم تماس بدن. یک
util مشترک (utils/phoneNumberMasking.js) شماره‌های ایرانی رو حتی وقتی
رقم‌ها با فاصله/خط‌فاصله/نقطه از هم جدا شده باشن تشخیص می‌ده و فقط همون
بخش رو با * جایگزین می‌کنه — بدون اینکه به قیمت/سایز/کد سفارش و بقیه‌ی
اعدادِ عادی دست بزنه. موقعِ ذخیره (نه نمایش) اعمال می‌شه، پس هیچ endpointِ
خوندنی نیاز به تغییر نداره.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
payacom
2026-09-15 15:54:26 +03:30
parent 5f99516078
commit 26979057d7
8 changed files with 102 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ const {
respondProjectProfileIncomplete
} = require('../../../utils/projectProfile')
const { isVerifiedBadge } = require('../../../utils/verifyBadge')
const { maskPhoneNumbers } = require('../../../utils/phoneNumberMasking')
async function activateFreeProjectIfEligible (user, project) {
if (project.project_type !== 'free') return { activated: false }
@@ -207,7 +208,7 @@ const createProject = async (req, res, next) => {
address: address || null,
offer_time,
offer_price,
description,
description: maskPhoneNumbers(description),
...(payment_method ? { payment_method } : {}),
start_date: start_date || null,
work_hours_start: work_hours_start || null,

View File

@@ -15,6 +15,7 @@ const {
canCreateProject,
respondProjectProfileIncomplete
} = require('../../../utils/projectProfile')
const { maskPhoneNumbers } = require('../../../utils/phoneNumberMasking')
const saveProjectComment = async ({
targetUserId,
projectId,
@@ -386,7 +387,7 @@ const editProject = async (req, res, next) => {
project.address = address || null
project.offer_time = offer_time
project.offer_price = offer_price
project.description = description
project.description = maskPhoneNumbers(description)
if (payment_method) project.payment_method = payment_method
project.start_date = start_date || null
project.work_hours_start = work_hours_start || null