Skip to content

Commit 9a26858

Browse files
committed
Merge branch 'dev'
2 parents 4fb1fc9 + d36a35e commit 9a26858

8 files changed

Lines changed: 21 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
# Release V2.2.1 (2022-12-18)
4+
5+
- Fix Mastodon not posting screenshots
6+
- Fix Take-Off messages not being sent
7+
38
# Release V2.2.0 (2022-12-17)
49

510
- Add Mastodon Support

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ The following TrackSources are supported:
4646
- VRS - This connects to your own Virtual Radar Server | (Self-Hosted)
4747
- OPSN - OpenSkyNetwork | (https://openskynetwork.github.io/opensky-api/rest.html)
4848
- dump1090 - Dump1090 Aircraft.Json | Get data from your local Dump1090 Feeder
49-
At this time airlines, squawk and type queries are only supported by the FachaDev TrackSource, and will not work if
50-
another source is selected
49+
50+
At this time airlines, squawk and type queries are only supported by the FachaDev TrackSource, and will not work if
51+
another source is selected
5152

5253
## Usage
5354

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "planealert",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "",
55
"main": "index.js",
66
"engines": {

src/models/Aircraft.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ export class Aircraft {
159159
if (nearestAirport !== null) {
160160
PlaneAlert.log.info(`Plane ${this.name} (${this.icao}) took off at ${nearestAirport.airport.name} (${nearestAirport.airport.gps_code})`);
161161
// Check altitude
162-
// @ts-ignore
163-
if (this.aircraft[i].meta.alt != null && this.aircraft[i].meta.alt <= PlaneAlert.config.thresholds.takeoff) {
162+
if (this.meta.alt != null && this.meta.alt <= PlaneAlert.config.thresholds.takeoff) {
164163
EventUtils.triggerEvent(PlaneEvents.PLANE_TAKEOFF, this, null, {nearestAirport: nearestAirport?.airport});
165164
}
166165
} else {

src/models/Airline.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ export class Airline {
199199
if (nearestAirport !== null) {
200200
PlaneAlert.log.debug(`Plane ${this.name} (${element.icao}) is near ${nearestAirport.airport!.name!} (${nearestAirport.airport!.ident!}) and has lost signal`);
201201
// Check altitude
202-
// @ts-ignore
203202
if (element.meta.alt != null && element.meta.alt <= PlaneAlert.config.thresholds.landing) {
204203

205204
PlaneAlert.log.info(`Plane ${this.name} (${element.icao}) is at ${element.meta.alt} ft and has lost signal. Suspected landing`);
@@ -228,7 +227,6 @@ export class Airline {
228227
if (nearestAirport !== null) {
229228
PlaneAlert.log.info(`Plane ${this.name} (${element.icao}) took off at ${nearestAirport.airport.name} (${nearestAirport.airport.gps_code})`);
230229
// Check altitude
231-
// @ts-ignore
232230
if (element.meta.alt != null && element.meta.alt <= PlaneAlert.config.thresholds.takeoff) {
233231
EventUtils.triggerEvent(PlaneEvents.PLANE_TAKEOFF, element, this, {nearestAirport: nearestAirport?.airport});
234232
}

src/utils/EventUtils.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class EventUtils {
8686
url: account.url,
8787
accessToken: account.accessToken,
8888
});
89-
let media: Attachment;
89+
let media: Attachment | undefined = undefined;
9090
if (hasTakeoffScreenshot) {
9191
try {
9292
media = await masto.mediaAttachments.create({
@@ -101,8 +101,7 @@ export class EventUtils {
101101
await masto.statuses.create({
102102
status: `${notificationName}${aircraft.callsign ? " flight #" + aircraft.callsign : ""} (#${aircraft.registration}) took off from ${data.nearestAirport.name} at ${new Date().toLocaleString()}\n${adsbExchangeLink}`,
103103
visibility: 'public',
104-
// @ts-ignore
105-
mediaIds: hasTakeoffScreenshot ? [media.id] : undefined,
104+
mediaIds: media ? [media.id] : undefined,
106105
});
107106
} catch (e) {
108107
PlaneAlert.log.error(`Plane ${notificationName} (${aircraft.icao}) could not send post to Mastodon: ${e}`);
@@ -178,7 +177,7 @@ export class EventUtils {
178177
url: account.url,
179178
accessToken: account.accessToken,
180179
});
181-
let media: Attachment;
180+
let media: Attachment | undefined = undefined;
182181
if (hasLandingScreenshot) {
183182
try {
184183
media = await masto.mediaAttachments.create({
@@ -193,8 +192,7 @@ export class EventUtils {
193192
await masto.statuses.create({
194193
status: `${notificationName}${aircraft.callsign ? " flight #" + aircraft.callsign : ""} (#${aircraft.registration}) landed at ${data.nearestAirport.name} at ${new Date().toLocaleString()}\n${adsbExchangeLink}`,
195194
visibility: 'public',
196-
// @ts-ignore
197-
mediaIds: hasTakeoffScreenshot ? [media.id] : undefined,
195+
mediaIds: media ? [media.id] : undefined,
198196
});
199197
} catch (e) {
200198
PlaneAlert.log.error(`Plane ${notificationName} (${aircraft.icao}) could not send post to Mastodon: ${e}`);
@@ -264,7 +262,7 @@ export class EventUtils {
264262
url: account.url,
265263
accessToken: account.accessToken,
266264
});
267-
let media: Attachment;
265+
let media: Attachment | undefined = undefined;
268266
if (hasEmergencyScreenshot) {
269267
try {
270268
media = await masto.mediaAttachments.create({
@@ -279,8 +277,7 @@ export class EventUtils {
279277
await masto.statuses.create({
280278
status: `${notificationName}${aircraft.callsign ? " flight #" + aircraft.callsign : ""} is squawking #${data.squawk} (${PlaneUtils.getEmergencyType(data.squawk)}) at ${new Date().toLocaleString()}\n${adsbExchangeLink}`,
281279
visibility: 'public',
282-
// @ts-ignore
283-
mediaIds: hasTakeoffScreenshot ? [media.id] : undefined,
280+
mediaIds: media ? [media.id] : undefined,
284281
});
285282
} catch (e) {
286283
PlaneAlert.log.error(`Plane ${notificationName} (${aircraft.icao}) could not send post to Mastodon: ${e}`);

src/utils/GeoUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export class GeoUtils {
2424
if (aircraft.meta.lon === null || aircraft.meta.lat === null || PlaneAlert.airports === null) {
2525
return null;
2626
}
27+
if (aircraft.meta.lon === undefined || aircraft.meta.lat === undefined) {
28+
return null;
29+
}
2730
PlaneAlert.log.debug(`Plane ${this.name} (${aircraft.icao}) searching for nearest airport of ${aircraft.meta.lat}/${aircraft.meta.lon}`);
2831
let min_distance: number = PlaneAlert.config.thresholds.landingNearestSuitableAirportDistance;
2932
let nearest_airport = null;

0 commit comments

Comments
 (0)