Fix #7731 - telegram improvemnts
[Pman.MTrack] / DataObjects / Mtrack_change.php
index 3c9d76f..c1e5cf1 100644 (file)
@@ -763,15 +763,27 @@ class Pman_MTrack_DataObjects_Mtrack_change extends DB_DataObject
             $str[] = $a->toAuditString($this);
         }
         
-        $res = $tg->factory('SendMessage',array(
-            'chat_id' => 35721679, 
-            'parse_mode' => 'MarkdownV2',
-            'text' => "/ticket@{$this->onid}  *". $tg->escape($t->summary) . "*\n\n".
-                    "{$this->cgtype} by ". $tg->escape($this->person()->name) . "\n\n" . $tg->escape(implode("\n", $str))
-                
-          
-        ))->send();
-         
+        // who to send to..
+        $d = DB_DataObject::factory('core_person');
+        $d->whereAddIn('id', array($t->created_person_id, $t->developer_id));
+        $d->whereAdd('telegram_id > 0');
+        $sendto = $d->fetchAll('id','telegram_id');
+        
+        // creator  //created_person_id
+        // assigned to developer_id
+        // exclude whoever modfiied it? (disable for testing.)
+        foreach($sendto as $pid => $tid) { 
+            if ($this->person_id == $pid) {
+                // continue;
+            }
+            $res = $tg->factory('SendMessage',array(
+                'chat_id' => $tid, 
+                'parse_mode' => 'MarkdownV2',
+                'text' => "/ticket@{$this->onid}  *". $tg->escape("[{$t->project_id_name}]] {$t->summary}") . "*\n\n".
+                        "{$this->cgtype} by ". $tg->escape($this->person()->name) . "\n\n" . $tg->escape(implode("\n", $str))
+            ))->send();
+        }
+        
         //print_R($res); 
     }