Oprava sestavování URL pro ntfy
This commit is contained in:
parent
dc959543f4
commit
60563eaf0d
@ -73,12 +73,14 @@ export const ntfyCall = async (data: NotififaceInput) => {
|
|||||||
const today = formatDate(getToday());
|
const today = formatDate(getToday());
|
||||||
let clientData: ClientData = await storage.getData(today);
|
let clientData: ClientData = await storage.getData(today);
|
||||||
const userByCLocation = getUsersByLocation(clientData.choices, data.user)
|
const userByCLocation = getUsersByLocation(clientData.choices, data.user)
|
||||||
|
// Odstraníme mezery a diakritiku a převedeme na lowercase
|
||||||
|
const topic = data.user.normalize('NFD').replace(' ', '').replace(/[\u0300-\u036f]/g, '').toLowerCase();
|
||||||
|
|
||||||
const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64');
|
const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64');
|
||||||
const promises = userByCLocation.map(async user => {
|
const promises = userByCLocation.map(async user => {
|
||||||
try {
|
try {
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
url: `${url}/${user}`,
|
url: `${url}/${topic}`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: `${data.udalost} - spustil:${data.user}`,
|
data: `${data.udalost} - spustil:${data.user}`,
|
||||||
headers: {
|
headers: {
|
||||||
@ -99,9 +101,6 @@ export const ntfyCall = async (data: NotififaceInput) => {
|
|||||||
export const callNotifikace = async ({ input, teams = true, gotify = false, ntfy = true }: NotifikaceData) => {
|
export const callNotifikace = async ({ input, teams = true, gotify = false, ntfy = true }: NotifikaceData) => {
|
||||||
const notifications = [];
|
const notifications = [];
|
||||||
if (ntfy) {
|
if (ntfy) {
|
||||||
if (input.user) {
|
|
||||||
input.user = input.user.normalize('NFD').replace(' ', '').replace(/[\u0300-\u036f]/g, '').toLowerCase();
|
|
||||||
}
|
|
||||||
const ntfyPromises = await ntfyCall(input);
|
const ntfyPromises = await ntfyCall(input);
|
||||||
if (ntfyPromises) {
|
if (ntfyPromises) {
|
||||||
notifications.push(...ntfyPromises);
|
notifications.push(...ntfyPromises);
|
||||||
|
@ -116,6 +116,7 @@ router.post("/jdemeObed", async (req, res, next) => {
|
|||||||
const login = getLogin(parseToken(req));
|
const login = getLogin(parseToken(req));
|
||||||
try {
|
try {
|
||||||
await callNotifikace({ input: { user: login, udalost: UdalostEnum.JDEME_OBED }, gotify: false })
|
await callNotifikace({ input: { user: login, udalost: UdalostEnum.JDEME_OBED }, gotify: false })
|
||||||
|
res.status(200).json({});
|
||||||
} catch (e: any) { next(e) }
|
} catch (e: any) { next(e) }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user