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());
|
||||
let clientData: ClientData = await storage.getData(today);
|
||||
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 promises = userByCLocation.map(async user => {
|
||||
try {
|
||||
const response = await axios({
|
||||
url: `${url}/${user}`,
|
||||
url: `${url}/${topic}`,
|
||||
method: 'POST',
|
||||
data: `${data.udalost} - spustil:${data.user}`,
|
||||
headers: {
|
||||
@ -99,9 +101,6 @@ export const ntfyCall = async (data: NotififaceInput) => {
|
||||
export const callNotifikace = async ({ input, teams = true, gotify = false, ntfy = true }: NotifikaceData) => {
|
||||
const notifications = [];
|
||||
if (ntfy) {
|
||||
if (input.user) {
|
||||
input.user = input.user.normalize('NFD').replace(' ', '').replace(/[\u0300-\u036f]/g, '').toLowerCase();
|
||||
}
|
||||
const ntfyPromises = await ntfyCall(input);
|
||||
if (ntfyPromises) {
|
||||
notifications.push(...ntfyPromises);
|
||||
|
@ -116,6 +116,7 @@ router.post("/jdemeObed", async (req, res, next) => {
|
||||
const login = getLogin(parseToken(req));
|
||||
try {
|
||||
await callNotifikace({ input: { user: login, udalost: UdalostEnum.JDEME_OBED }, gotify: false })
|
||||
res.status(200).json({});
|
||||
} catch (e: any) { next(e) }
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user