| @@ -51,11 +51,12 @@ | ||
| 51 | 51 | * mxchat_options. |
| 52 | 52 | */ |
| 53 | 53 | const OPTION = 'mxchat_live_agent_schedule'; |
| 54 | 54 | |
| 55 | - /** Per-channel standalone options (plan 99d7a4). */ | |
| 55 | + /** Per-channel standalone options (plan 99d7a4; webhook added by d88e22). */ | |
| 56 | 56 | const OPTION_SLACK = 'mxchat_live_agent_schedule_slack'; |
| 57 | 57 | const OPTION_TELEGRAM = 'mxchat_live_agent_schedule_telegram'; |
| 58 | + const OPTION_WEBHOOK = 'mxchat_live_agent_schedule_webhook'; | |
| 58 | 59 | |
| 59 | 60 | /* ------------------------------------------------------------------ * |
| 60 | 61 | * Channels |
| 61 | 62 | * ------------------------------------------------------------------ */ |
| @@ -61,9 +62,9 @@ | ||
| 61 | 62 | * ------------------------------------------------------------------ */ |
| 62 | 63 | |
| 63 | 64 | /** The channels that carry a schedule. Key = channel id used across the API. */ |
| 64 | 65 | public static function channels() { |
| 65 | - return array('slack', 'telegram'); | |
| 66 | + return array('slack', 'telegram', 'webhook'); | |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | 69 | /** |
| 69 | 70 | * Resolve a channel id to its option name. Unknown input maps to Slack — |
| @@ -70,9 +71,15 @@ | ||
| 70 | 71 | * every real call site passes a literal, so this is a typo net, not a |
| 71 | 72 | * routing feature. |
| 72 | 73 | */ |
| 73 | 74 | private static function option_name($channel) { |
| 74 | - return ($channel === 'telegram') ? self::OPTION_TELEGRAM : self::OPTION_SLACK; | |
| 75 | + if ($channel === 'telegram') { | |
| 76 | + return self::OPTION_TELEGRAM; | |
| 77 | + } | |
| 78 | + if ($channel === 'webhook') { | |
| 79 | + return self::OPTION_WEBHOOK; | |
| 80 | + } | |
| 81 | + return self::OPTION_SLACK; | |
| 75 | 82 | } |
| 76 | 83 | |
| 77 | 84 | /** |
| 78 | 85 | * One-time seed of the per-channel options from the legacy shared option. |
| @@ -92,8 +99,10 @@ | ||
| 92 | 99 | if (!is_array($legacy)) { |
| 93 | 100 | return; |
| 94 | 101 | } |
| 95 | 102 | $seed = self::normalize($legacy); |
| 103 | + // Webhook (d88e22) is deliberately NOT seeded: the legacy shared option | |
| 104 | + // predates the webhook channel, so it never expressed intent about it. | |
| 96 | 105 | foreach (array(self::OPTION_SLACK, self::OPTION_TELEGRAM) as $opt) { |
| 97 | 106 | if (!is_array(get_option($opt, null))) { |
| 98 | 107 | update_option($opt, $seed); |
| 99 | 108 | } |