
const express = require('express');
const router = express.Router();
const User = require('../models/User');


router.use('/users', require('../routes/users.js'));


function canViewMessage(user, message) {
  return (
    // user.role === ROLE.ADMIN ||
    message.to === user.phone || 
    message.fromPhone === user.phone 
  )
}

// function scopedMessages(user, projects) {
//   if (user.role === ROLE.ADMIN) return projects
//   return projects.filter(project => project.userId === user.id)
// }

function canDeleteMessage(user, message) {
  return message.fromPhone === user.phone
}

module.exports = {
  canViewMessage,
  // scopedMessages,
  canDeleteMessage
}