|  | @@ -9,19 +9,20 @@ const jwt = require('jsonwebtoken')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  exports.addUserPublic = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |    const { no_laporan, pt_id, nama, email, no_hp, alamat, is_private } = req.body
 | 
	
		
			
				|  |  | -  const no_hp2 =
 | 
	
		
			
				|  |  | -    no_hp.substring(0, 1) === '0' ? '62' + no_hp.substring(1) : no_hp
 | 
	
		
			
				|  |  |    const isValid = validate(res, req.body, {
 | 
	
		
			
				|  |  |      no_laporan: 'string',
 | 
	
		
			
				|  |  |      pt_id: 'string',
 | 
	
		
			
				|  |  | -    nama: 'string',
 | 
	
		
			
				|  |  | -    email: 'email',
 | 
	
		
			
				|  |  | +    // nama: 'string',
 | 
	
		
			
				|  |  | +    // email: 'email',
 | 
	
		
			
				|  |  |      no_hp: 'string',
 | 
	
		
			
				|  |  | -    alamat: 'string',
 | 
	
		
			
				|  |  | +    // alamat: 'string',
 | 
	
		
			
				|  |  |      is_private: { type: 'string', enum: ['true', 'false'] },
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  |    if (!isValid) return
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  const no_hp2 =
 | 
	
		
			
				|  |  | +    no_hp.substring(0, 1) === '0' ? '62' + no_hp.substring(1) : no_hp
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    const pt = await axios.get(
 | 
	
		
			
				|  |  |      `https://api.kemdikbud.go.id:8243/pddikti/1.2/pt/${pt_id}`
 | 
	
		
			
				|  |  |    )
 | 
	
	
		
			
				|  | @@ -30,16 +31,14 @@ exports.addUserPublic = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |        message: 'pt_id tidak ditemukan',
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  let foto_id = null
 | 
	
		
			
				|  |  |    const foto = req.file
 | 
	
		
			
				|  |  | -  if (!foto) {
 | 
	
		
			
				|  |  | -    return response.error(res, {
 | 
	
		
			
				|  |  | -      message: 'foto harus ada',
 | 
	
		
			
				|  |  | -    })
 | 
	
		
			
				|  |  | +  if (foto) {
 | 
	
		
			
				|  |  | +    foto_id = await addDokumen(foto)
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  const foto_id = await addDokumen(foto)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const no_verifikasi = Math.floor(Math.random() * 1000000)
 | 
	
		
			
				|  |  | -  const user = await userModel.create({
 | 
	
		
			
				|  |  | +  let data = {
 | 
	
		
			
				|  |  |      nama,
 | 
	
		
			
				|  |  |      email,
 | 
	
		
			
				|  |  |      no_hp,
 | 
	
	
		
			
				|  | @@ -49,11 +48,27 @@ exports.addUserPublic = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |      foto: foto_id,
 | 
	
		
			
				|  |  |      no_verifikasi,
 | 
	
		
			
				|  |  |      verified: false,
 | 
	
		
			
				|  |  | -  })
 | 
	
		
			
				|  |  | +    priority: 'low',
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  if (
 | 
	
		
			
				|  |  | +    no_laporan &&
 | 
	
		
			
				|  |  | +    pt_id &&
 | 
	
		
			
				|  |  | +    nama &&
 | 
	
		
			
				|  |  | +    email &&
 | 
	
		
			
				|  |  | +    no_hp &&
 | 
	
		
			
				|  |  | +    alamat &&
 | 
	
		
			
				|  |  | +    is_private &&
 | 
	
		
			
				|  |  | +    foto_id
 | 
	
		
			
				|  |  | +  ) {
 | 
	
		
			
				|  |  | +    data.priority = 'hight'
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  const user = await userModel.create(data)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    await notifWA2(
 | 
	
		
			
				|  |  |      '37a9ccba-e1bc-4d02-86e0-3be4c718af2a',
 | 
	
		
			
				|  |  | -    { nama, no_hp: no_hp2 },
 | 
	
		
			
				|  |  | +    { nama: nama || 'rahasia', no_hp: no_hp2 },
 | 
	
		
			
				|  |  |      [
 | 
	
		
			
				|  |  |        { key: '1', value: 'pt', value_text: pt[0].nama },
 | 
	
		
			
				|  |  |        { key: '3', value: 'no_verifikasi', value_text: no_verifikasi },
 | 
	
	
		
			
				|  | @@ -69,7 +84,7 @@ exports.addUserPublic = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    )
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  const data = {
 | 
	
		
			
				|  |  | +  data = {
 | 
	
		
			
				|  |  |      token: `Bearer ${accessToken}`,
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 |