fix merge
authorAlan <alan@roojs.com>
Tue, 11 Jul 2023 07:07:24 +0000 (15:07 +0800)
committerAlan <alan@roojs.com>
Tue, 11 Jul 2023 07:07:24 +0000 (15:07 +0800)
DataObjects/Mtrack_change.php
DataObjects/Mtrack_ticket.php

index 6a6e95c..55ac511 100644 (file)
@@ -33,6 +33,7 @@ class Pman_MTrack_DataObjects_Mtrack_change extends DB_DataObject
             $cache[$this->ontable.':'. $this->onid];
         }
         $o = DB_DataObject::factory($this->ontable);
+        $o->autoJoin();
         $o->get($this->onid);
         $cache[$this->ontable.':'. $this->onid] = $o;
         return $o;
@@ -762,17 +763,30 @@ class Pman_MTrack_DataObjects_Mtrack_change extends DB_DataObject
         foreach ($this->audit() as $a) {
             $str[] = $a->toAuditString($this);
         }
+        // who to send to..
+        $d = DB_DataObject::factory('core_person');
+        $d->whereAddIn('id', array($t->created_person_id, $t->developer_id), 'int');
+        $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();
+        }
         
-        $res = $tg->factory('SendMessage',array(
-            'chat_id' => 35721679,   // fixme - this needs to be mapped to who we are sending to (currently it's only me!!!)
-            '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();
-         
-        //print_R($res); 
+         //print_R($res); 
     }
 
     
index fb3612b..cab8912 100644 (file)
@@ -894,7 +894,9 @@ class Pman_MTrack_DataObjects_Mtrack_ticket extends DB_DataObject
             $this->updateUploads(json_decode($req['uploads']), $roo);
         }
         // in theory this should trigger a timesheet log that we have started working on something.
-        
+        if ($ch) {
+            $ch->sendTelegram();
+        }
         
         
     }