( request: ReportCreationRequest, reportID: string, username: ?string, )
| 135 | } |
| 136 | |
| 137 | function getCommbotMessage( |
| 138 | request: ReportCreationRequest, |
| 139 | reportID: string, |
| 140 | username: ?string, |
| 141 | ): ?string { |
| 142 | const name = username ? username : '[null]'; |
| 143 | const { platformDetails } = request; |
| 144 | const { platform, codeVersion } = platformDetails; |
| 145 | const platformString = codeVersion ? `${platform} v${codeVersion}` : platform; |
| 146 | if (request.type === reportTypes.ERROR) { |
| 147 | const { baseDomain, basePath } = getAndAssertKeyserverURLFacts(); |
| 148 | return ( |
| 149 | `${name} got an error :(\n` + |
| 150 | `using ${platformString}\n` + |
| 151 | `${baseDomain}${basePath}download_error_report/${reportID}` |
| 152 | ); |
| 153 | } else if (request.type === reportTypes.THREAD_INCONSISTENCY) { |
| 154 | const nonMatchingThreadIDs = getInconsistentThreadIDsFromReport(request); |
| 155 | const nonMatchingString = [...nonMatchingThreadIDs].join(', '); |
| 156 | return ( |
| 157 | `system detected inconsistency for ${name}!\n` + |
| 158 | `using ${platformString}\n` + |
| 159 | `occurred during ${request.action.type}\n` + |
| 160 | `thread IDs that are inconsistent: ${nonMatchingString}` |
| 161 | ); |
| 162 | } else if (request.type === reportTypes.ENTRY_INCONSISTENCY) { |
| 163 | const nonMatchingEntryIDs = getInconsistentEntryIDsFromReport(request); |
| 164 | const nonMatchingString = [...nonMatchingEntryIDs].join(', '); |
| 165 | return ( |
| 166 | `system detected inconsistency for ${name}!\n` + |
| 167 | `using ${platformString}\n` + |
| 168 | `occurred during ${request.action.type}\n` + |
| 169 | `entry IDs that are inconsistent: ${nonMatchingString}` |
| 170 | ); |
| 171 | } else if (request.type === reportTypes.USER_INCONSISTENCY) { |
| 172 | const nonMatchingUserIDs = getInconsistentUserIDsFromReport(request); |
| 173 | const nonMatchingString = [...nonMatchingUserIDs].join(', '); |
| 174 | return ( |
| 175 | `system detected inconsistency for ${name}!\n` + |
| 176 | `using ${platformString}\n` + |
| 177 | `occurred during ${request.action.type}\n` + |
| 178 | `user IDs that are inconsistent: ${nonMatchingString}` |
| 179 | ); |
| 180 | } else if (request.type === reportTypes.MEDIA_MISSION) { |
| 181 | const mediaMissionJSON = JSON.stringify(request.mediaMission); |
| 182 | const success = request.mediaMission.result.success |
| 183 | ? 'media mission success!' |
| 184 | : 'media mission failed :('; |
| 185 | return `${name} ${success}\n` + mediaMissionJSON; |
| 186 | } else { |
| 187 | return null; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | function findInconsistentObjectKeys<O>( |
| 192 | first: { +[id: string]: O }, |
no test coverage detected