Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "fix: affected status report monitors"

This reverts commit 9930df79368efe78e9a4c891d2c24606d67fe687.

+37 -68
+14 -19
apps/server/src/routes/v1/statusReportUpdates/post.ts
··· 45 45 }); 46 46 47 47 export function registerPostStatusReportUpdate( 48 - api: typeof statusReportUpdatesApi 48 + api: typeof statusReportUpdatesApi, 49 49 ) { 50 50 return api.openapi(createStatusUpdate, async (c) => { 51 51 const workspaceId = c.get("workspace").id; 52 52 const input = c.req.valid("json"); 53 53 const limits = c.get("workspace").limits; 54 54 55 - const _statusReport = await db.query.statusReport.findFirst({ 56 - where: and( 57 - eq(statusReport.id, input.statusReportId), 58 - eq(statusReport.workspaceId, workspaceId) 59 - ), 60 - with: { 61 - monitorsToStatusReports: { 62 - with: { 63 - monitor: true, 64 - }, 65 - }, 66 - }, 67 - }); 55 + const _statusReport = await db 56 + .select() 57 + .from(statusReport) 58 + .where( 59 + and( 60 + eq(statusReport.id, input.statusReportId), 61 + eq(statusReport.workspaceId, workspaceId), 62 + ), 63 + ) 64 + .get(); 68 65 69 66 if (!_statusReport) { 70 67 throw new OpenStatusApiError({ ··· 90 87 .where( 91 88 and( 92 89 eq(pageSubscriber.pageId, _statusReport.pageId), 93 - isNotNull(pageSubscriber.acceptedAt) 94 - ) 90 + isNotNull(pageSubscriber.acceptedAt), 91 + ), 95 92 ) 96 93 .all(); 97 94 ··· 114 111 status: _statusReport.status, 115 112 message: _statusReportUpdate.message, 116 113 date: _statusReportUpdate.date.toISOString(), 117 - monitors: _statusReport.monitorsToStatusReports.map( 118 - (i) => i.monitor.name 119 - ), 114 + monitors: _page.monitorsToPages.map((i) => i.monitor.name), 120 115 }); 121 116 } 122 117 }
+7 -27
apps/server/src/routes/v1/statusReports/post.ts
··· 71 71 and( 72 72 eq(monitor.workspaceId, workspaceId), 73 73 inArray(monitor.id, input.monitorIds), 74 - isNull(monitor.deletedAt) 75 - ) 74 + isNull(monitor.deletedAt), 75 + ), 76 76 ) 77 77 .all(); 78 78 79 79 if (_monitors.length !== input.monitorIds.length) { 80 80 throw new OpenStatusApiError({ 81 81 code: "BAD_REQUEST", 82 - message: `Some of the monitors ${input.monitorIds.join( 83 - ", " 84 - )} not found`, 82 + message: `Some of the monitors ${input.monitorIds.join(", ")} not found`, 85 83 }); 86 84 } 87 85 } ··· 130 128 monitorId: id, 131 129 statusReportId: _newStatusReport.id, 132 130 }; 133 - }) 131 + }), 134 132 ) 135 133 .returning(); 136 134 } ··· 142 140 .where( 143 141 and( 144 142 eq(pageSubscriber.pageId, _newStatusReport.pageId), 145 - isNotNull(pageSubscriber.acceptedAt) 146 - ) 143 + isNotNull(pageSubscriber.acceptedAt), 144 + ), 147 145 ) 148 146 .all(); 149 147 ··· 158 156 }, 159 157 }); 160 158 161 - const _statusReport = await db.query.statusReport.findFirst({ 162 - where: eq(statusReport.id, _newStatusReport.id), 163 - with: { 164 - monitorsToStatusReports: { 165 - with: { monitor: true }, 166 - }, 167 - }, 168 - }); 169 - 170 - if (!_statusReport) { 171 - throw new OpenStatusApiError({ 172 - code: "INTERNAL_SERVER_ERROR", 173 - message: "Status report not found", 174 - }); 175 - } 176 - 177 159 if (pageInfo && subscribers.length > 0) { 178 160 await emailClient.sendStatusReportUpdate({ 179 161 to: subscribers.map((subscriber) => subscriber.email), ··· 182 164 status: _newStatusReport.status, 183 165 message: _newStatusReportUpdate.message, 184 166 date: _newStatusReportUpdate.date.toISOString(), 185 - monitors: _statusReport.monitorsToStatusReports.map( 186 - (i) => i.monitor.name 187 - ), 167 + monitors: pageInfo.monitorsToPages.map((i) => i.monitor.name), 188 168 }); 189 169 } 190 170 }
+11 -11
apps/server/src/routes/v1/statusReports/update/post.ts
··· 59 59 .where( 60 60 and( 61 61 eq(statusReport.id, Number(id)), 62 - eq(statusReport.workspaceId, workspaceId) 63 - ) 62 + eq(statusReport.workspaceId, workspaceId), 63 + ), 64 64 ) 65 65 .returning() 66 66 .get(); ··· 84 84 .get(); 85 85 86 86 if (limits.notifications && _statusReport.pageId) { 87 - const _statusReportWithRelations = await db.query.statusReport.findFirst({ 87 + const allInfo = await db.query.statusReport.findFirst({ 88 88 where: eq(statusReport.id, Number(id)), 89 89 with: { 90 90 monitorsToStatusReports: { ··· 102 102 .where( 103 103 and( 104 104 eq(pageSubscriber.pageId, _statusReport.pageId), 105 - isNotNull(pageSubscriber.acceptedAt) 106 - ) 105 + isNotNull(pageSubscriber.acceptedAt), 106 + ), 107 107 ) 108 108 .all(); 109 109 110 - if (_statusReportWithRelations?.page) { 110 + if (allInfo?.page) { 111 111 await emailClient.sendStatusReportUpdate({ 112 112 to: subscribers.map((subscriber) => subscriber.email), 113 - pageTitle: _statusReportWithRelations.page.title, 114 - reportTitle: _statusReportWithRelations.title, 115 - status: _statusReportWithRelations.status, 113 + pageTitle: allInfo.page.title, 114 + reportTitle: allInfo.title, 115 + status: allInfo.status, 116 116 message: _statusReportUpdate.message, 117 117 date: _statusReportUpdate.date.toISOString(), 118 - monitors: _statusReportWithRelations.monitorsToStatusReports.map( 119 - (monitor) => monitor.monitor.name 118 + monitors: allInfo.monitorsToStatusReports.map( 119 + (monitor) => monitor.monitor.name, 120 120 ), 121 121 }); 122 122 }
+5 -11
packages/api/src/router/email/index.ts
··· 25 25 with: { 26 26 statusReport: { 27 27 with: { 28 - monitorsToStatusReports: { 29 - with: { 30 - monitor: true, 31 - }, 32 - }, 33 28 page: { 34 29 with: { 35 30 pageSubscribers: { ··· 54 49 55 50 await emailClient.sendStatusReportUpdate({ 56 51 to: _statusReportUpdate.statusReport.page.pageSubscribers.map( 57 - (subscriber) => subscriber.email 52 + (subscriber) => subscriber.email, 58 53 ), 59 54 pageTitle: _statusReportUpdate.statusReport.page.title, 60 55 reportTitle: _statusReportUpdate.statusReport.title, 61 56 status: _statusReportUpdate.status, 62 57 message: _statusReportUpdate.message, 63 58 date: new Date(_statusReportUpdate.date).toISOString(), 64 - monitors: 65 - _statusReportUpdate.statusReport.monitorsToStatusReports.map( 66 - (i) => i.monitor.name 67 - ), 59 + monitors: _statusReportUpdate.statusReport.page.monitorsToPages.map( 60 + (i) => i.monitor.name, 61 + ), 68 62 }); 69 63 } 70 64 }), ··· 77 71 const _invitation = await opts.ctx.db.query.invitation.findFirst({ 78 72 where: and( 79 73 eq(invitation.id, opts.input.id), 80 - eq(invitation.workspaceId, opts.ctx.workspace.id) 74 + eq(invitation.workspaceId, opts.ctx.workspace.id), 81 75 ), 82 76 }); 83 77