From ad8477d3ee82a3fffd5de4cd60a237c9ee6b1fb7 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Wed, 04 Mar 2026 14:27:05 +0800
Subject: [PATCH] 后台添加供需求发布

---
 admin/app/common/model/plus/release/Chat.php |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/admin/app/common/model/plus/release/Chat.php b/admin/app/common/model/plus/release/Chat.php
index bebf8c5..1912d2e 100644
--- a/admin/app/common/model/plus/release/Chat.php
+++ b/admin/app/common/model/plus/release/Chat.php
@@ -25,12 +25,18 @@
     //添加信息
     public function add($postdata,$user)
     {
+        // 验证:不能给自己发消息
+        if (!isset($postdata['you_user_id']) || $postdata['you_user_id'] == $user['user_id']) {
+            $this->error = '不能给自己发消息';
+            return false;
+        }
+
         // 开启事务
         $this->startTrans();
         try {
-            
+
             $ChatRelation = new ChatRelation();
-            
+
             $info = $ChatRelation->where('user_id', '=', $user['user_id'])->where('other_user_id', '=', $postdata['you_user_id'])->find();
             if(empty($info)){
                 $info = $ChatRelation->where('user_id', '=', $postdata['you_user_id'])->where('other_user_id', '=', $user['user_id'])->find();

--
Gitblit v1.9.2