-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81db992
commit 08df6df
Showing
10 changed files
with
36 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createRestAPIClient } from 'npm:[email protected]'; | ||
import { createRestAPIClient } from "npm:[email protected]"; | ||
import mastodonConfig from "../config/mastodon.config.ts"; | ||
import logger from "../services/logger.service.ts"; | ||
import mqttService from "../services/mqtt.service.ts"; | ||
|
@@ -12,11 +12,11 @@ export default function publishMastodon() { | |
if (err) { | ||
logger.error(err.toString()); | ||
} else { | ||
logger.info("Listening MQTT Topic") | ||
logger.info("Listening MQTT Topic"); | ||
} | ||
}); | ||
}) | ||
mqttService.on("message", async (topic, message) => { | ||
}); | ||
mqttService.on("message", async (_topic, message) => { | ||
try { | ||
const decodedMessage: PubSubMessage = JSON.parse(message.toString()); | ||
logger.debug(decodedMessage); | ||
|
@@ -25,14 +25,14 @@ export default function publishMastodon() { | |
.replace(/{channelName}/g, decodedMessage.title) | ||
.replace(/{mentionUser}/g, decodedMessage.mastodon ? ` (${decodedMessage.mastodon})` : ``) | ||
.replace(/{title}/g, decodedMessage.entryTitle) | ||
.replace(/{url}/g, decodedMessage.entryLink) | ||
.replace(/{url}/g, decodedMessage.entryLink); | ||
|
||
const mastodon = await createRestAPIClient(mastodonConfig[decodedMessage.type]); | ||
const status = await mastodon.v1.statuses.create({ status: messageStatus, visibility: 'public', }); | ||
const status = await mastodon.v1.statuses.create({ status: messageStatus, visibility: "public" }); | ||
logger.info(messageStatus, status.url); | ||
} catch (error) { | ||
logger.error(error); | ||
logger.error(message.toString()); | ||
} | ||
}) | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { TwitterApi } from 'npm:[email protected]'; | ||
import { TwitterApi } from "npm:[email protected]"; | ||
import twitterConfig from "../config/twitter.config.ts"; | ||
import logger from "../services/logger.service.ts"; | ||
import mqttService from "../services/mqtt.service.ts"; | ||
|
@@ -12,11 +12,11 @@ export default function publishTwitter() { | |
if (err) { | ||
logger.error(err.toString()); | ||
} else { | ||
logger.info("Listening MQTT Topic") | ||
logger.info("Listening MQTT Topic"); | ||
} | ||
}); | ||
}) | ||
mqttService.on("message", async (topic, message) => { | ||
}); | ||
mqttService.on("message", async (_topic, message) => { | ||
try { | ||
const decodedMessage: PubSubMessage = JSON.parse(message.toString()); | ||
logger.debug(decodedMessage); | ||
|
@@ -25,7 +25,7 @@ export default function publishTwitter() { | |
.replace(/{channelName}/g, decodedMessage.title) | ||
.replace(/{mentionUser}/g, decodedMessage.twitter ? ` (${decodedMessage.twitter})` : ``) | ||
.replace(/{title}/g, decodedMessage.entryTitle) | ||
.replace(/{url}/g, decodedMessage.entryLink) | ||
.replace(/{url}/g, decodedMessage.entryLink); | ||
|
||
const twitter = new TwitterApi(twitterConfig[decodedMessage.type]); | ||
const status = await twitter.v2.tweet(messageStatus); | ||
|
@@ -34,5 +34,5 @@ export default function publishTwitter() { | |
logger.error(error); | ||
logger.error(message.toString()); | ||
} | ||
}) | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ export default interface PubSubMessage { | |
entryLink: string; | ||
twitter?: string; | ||
mastodon?: string; | ||
} | ||
} |