Skip to content

Commit 8690831

Browse files
committed
修复进度消息不包含图像时无法匹配任务导致的超时
1 parent 1141fb2 commit 8690831

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/Discord.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ public function createWss()
171171
Log::debug("DISCORD:{$this->id()} WSS Receive Message " . $data['t'] ?? '');
172172
}
173173
}
174+
// White list
175+
$titleWhiteList = [
176+
'Zoom Out',
177+
'Inpaint'
178+
];
179+
if (in_array($data['t'] ?? '', [Discord::INTERACTION_MODAL_CREATE, Discord::INTERACTION_IFRAME_MODAL_CREATE]) && !in_array($data['d']['title'] ?? '', $titleWhiteList)) {
180+
file_put_contents(runtime_path('logs/midjourney/midjourney.warning.log'), date('Y-m-d H:i:s') . ' ' . ($data['d']['title'] ?? '') . "\n", FILE_APPEND);
181+
}
174182
switch ($code) {
175183
case Discord::MESSAGE_OPTION_HELLO:
176184
$this->handleHello($data);

src/MessageHandler/Success.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ public static function handle($message): bool
3636
$task = Discord::getRunningTaskByCondition((new TaskCondition())->prompt($finalPrompt)->params([Discord::INTERACTION_FAILURE => true]));
3737
if (!$task) {
3838
Log::debug("MessageHandler Success no task found messageHash=$messageHash messageId=$messageId nonce=$nonce and no InteractionFailure task found");
39-
return false;
39+
$task = Discord::getRunningTaskByCondition((new TaskCondition())->prompt($finalPrompt));
40+
if (!$task) {
41+
Log::debug("MessageHandler Success no task found messageHash=$messageHash messageId=$messageId nonce=$nonce prompt=$finalPrompt and no task found");
42+
return false;
43+
}
4044
}
4145
}
4246
$imageUrl = $message['d']['attachments'][0]['url'] ?? '';

src/TaskCondition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ public function match(Task $task): bool
116116
if ($this->messageHash !== null && $this->messageHash !== $task->messageHash()) {
117117
return false;
118118
}
119+
// 只查找prompt的任务时只查找messageHash为空的任务
120+
if ($this->prompt !== null && $this->nonce === null && $this->messageId === null && $this->messageHash === null && $task->messageHash()) {
121+
return false;
122+
}
119123
$params = $task->params();
120124
foreach ($this->params as $key => $value) {
121125
if (!isset($params[$key]) || $params[$key] != $value) {

0 commit comments

Comments
 (0)