MCPcopy Create free account
hub / github.com/CommE2E/comm / getCommbotMessage

Function getCommbotMessage

keyserver/src/creators/report-creator.js:137–189  ·  view source on GitHub ↗
(
  request: ReportCreationRequest,
  reportID: string,
  username: ?string,
)

Source from the content-addressed store, hash-verified

135}
136
137function 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
191function findInconsistentObjectKeys<O>(
192 first: { +[id: string]: O },

Callers 1

sendCommbotMessageFunction · 0.70

Tested by

no test coverage detected