preprocessExpiresField handles the common expires field preprocessing pattern. This function: 1. Parses the expires value through parseExpiresFromConfig (handles integers, strings, and boolean false) 2. Handles explicit disablement when expires=false (returns -1) 3. Normalizes the value to hours and
(configData map[string]any, debugLog *logger.Logger)
| 172 | // Returns true if expires was explicitly disabled with false, false otherwise. |
| 173 | // This helper consolidates duplicate preprocessing logic used in parseCreateIssuesConfig and parseCreateDiscussionsConfig. |
| 174 | func preprocessExpiresField(configData map[string]any, debugLog *logger.Logger) bool { |
| 175 | expiresDisabled := false |
| 176 | if configData != nil { |
| 177 | if expires, exists := configData["expires"]; exists { |
| 178 | expiresInt := parseExpiresFromConfig(configData) |
| 179 | if expiresInt == -1 { |
| 180 | expiresDisabled = true |
| 181 | configData["expires"] = 0 |
| 182 | } else if expiresInt > 0 { |
| 183 | configData["expires"] = expiresInt |
| 184 | } else { |
| 185 | configData["expires"] = 0 |
| 186 | } |
| 187 | if debugLog != nil { |
| 188 | debugLog.Printf("Parsed expires value %v to %d hours (disabled=%t)", expires, expiresInt, expiresDisabled) |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | return expiresDisabled |
| 193 | } |