Is it possible way for allow RTSP protocol in broadcasting?

I am using React SDK for Broadcasting with RTSP Link. But It’s not supporting. We got below error.

"chunk-K5SOP2KC.js?v=4001314d:8961 Uncaught (in promise) AgoraRTCException: AgoraRTCError INVALID_OPERATION: [LiveStreaming] no transcoding config found, can not start transcoding streaming task"

Here my code.

const agoraEngine = useRTCClient(AgoraRTC.createClient({ codec: "h264", mode: 'live' }));

 useJoin({
    appid: config.appId,
    channel: config.channelName,
    token: config.rtcToken,
    uid: config.uid,
  });

 usePublish([localCameraTrack,localMicrophoneTrack])

agoraEngine.setClientRole("host");
agoraEngine.setLiveTranscoding({width : 600 , height: 360,backgroundColor: 0x000000,  videoBitrate: 400,lowLatency: false})
agoraEngine.startLiveStreaming("rtsp://sampleurl/samplekey",true)

I am using React SDK for Broadcasting with RTSP Link. But It’s not supporting. We got below error.

chunk-K5SOP2KC.js?v=4001314d:8961 Uncaught (in promise) AgoraRTCException: AgoraRTCError INVALID_OPERATION: [LiveStreaming] no transcoding config found, can not start transcoding streaming task

I want to detect in-app browser of slack using javascript

I’m making a mobile website using NextJS and sharing the site link on Slack.
When the link is clicked, it opens within the in-app browser of Slack. However, I would like it to open in an external browser.

So I use navigator.useragent to detect the current browser condition.
For example, if I open the link in kakaotalk, the useragent includes a “kakaotalk” paragraph, allowing me to identify that it’s within the in-app browser of KakaoTalk.

However, when I open the link in Slack, then useragent don’t includes a “slack” paragraph and there’s no distinction between the in-app browser of Slack and an external browser.

How can I detect the in-app browser of slack?

My goal is to initially open my site within the in-app browser of Slack and then transition to an external browser.

Additionally, I used an Android phone, and I used Chrome as my browser

how to change mock object return value only for one test?

I have a simple suite of tests where in some cases I want to change mock a module value and in some cases not. Anyone has an idea how it to do?

this is my mock object inside mockConfig.js file

module.exports = {
  skillGames: {
    leftMenuWidget: {
      filterByBadge: 'exclusive',
      limit: 6,
      title: 'Exclusive games',
    },
  }
}

when I try mock mockConfig.js file for my test like this`

jest.mock('helpers/test/mockConfig', () => ({
      __esModule: true,
      skillGames: {
        leftMenuWidget: {
          limit: 6,
          title: 'Exclusive games',
        },
      },
    }));

I set filterByBadge value undefined for all tests, but me need that it will be undefined only for one test

CSS Transform Rotate will not allow elements inside div to rotate

I am basically trying to create flashcards but with food recipes, I want to show the name and title of a recipe and once you click on the card it flips to the back showing the recipe. I’m trying to use a handleflip function and it does switch the classes from card to card-flip but it is not rotating the elements inside the div.

   const [flip, setFlip] = useState(false);
    const handleFlip =() => {
        setFlip(!flip);
    };

    return (
        <div className={`card ${flip ? 'card-flip' : '' }`}onClick={handleFlip}>

            <div className="front">
                <div className="card-title" >
                    <h2 >{recipecard.title}</h2>
                </div>
                <div className="card-text">
                    <p >{recipecard.description}</p>
                </div>  
            </div>

            <div className="back">
                <div className="card-title">
                    <h2 >{recipecard.title}</h2>
                </div>
                <div className="card-text">
                    <p >{recipecard.ingredients}</p>
                </div>
            </div>

        </div> 
.card{
    display:flex;
    justify-content: center;
    position: relative;
    align-items: center;
    border: 1px solid rgb(187, 178, 178);
    transform-style:preserve-3d !important; 
    transform: perspective(1000px) rotateY(var(--rotate-y,0)); 
    height:450px;
    width: 450px;
    transition: transform 0.5s ease;
}
.card .card-flip{
    --rotate-y: 180deg;
}
.card .front,
.card .back {
    position:absolute;
    padding: 1rem;
    backface-visibility: hidden;
}
.card .front{
    transform: rotateY(0deg);
}
.card .back {
    transform: rotateY(180deg);
}

Ive consoled.logged to make sure the logic is correct and it does and the class is changing when its clicked but my front div is not rotating 180deg to become invisible, the transform value from the card class is also not changing to the card-flip classes value. Ive also tried it on chrome,edge and mozilla and theres not change in how it interacts with any browser.

Nextjs cache and cloudflare cache are not synced with getStaticProps revalidation

I’m trying to test my nextjs application on digital ocean, I deployed it, and noticed that getStaticProps revalidation doesn’t work, I examined the cache headers and notice that the revalidation paramater is being asssigned to Cache-Control like follow:

Cache-Control: s-maxage=10800, stale-while-revalidate

Which is what I am for, to tell nextjs to regenerate the page every 3 hours to update data. But the issue is, nextjs and cloudflare are not synced. So now the status is:

Cf-Cache-Status: HIT
X-Nextjs-Cache: STALE

Which means that for nextjs the page is expired, but for CF it’s not, so while nextjs might regenerate the page in the background it won’t show the new page until cloudflare cache will also expire.

Is there a way to fix it and sync them? Currently the application doesn’t have domain, so it’s all managed by digitalocean, but I am not sure if it’s digitalocean issue or next ~ cloudflare issue that I can fix by configuration on either side.

Hapi call one route from another and pass payload

I am currently using hapi.js and have been interacting with an API that contains specific logic. Now, I aim to leverage the same logic by invoking that route from another API.

This is my route where I have written all my logic

const routeConfig = {
    method: 'POST',
    path: "/first-route",
    config: {
        auth: { strategy: "jwt", mode: "optional" },
        handler
    }
}

Here I want to call above api and want to pass payload

const handler = async (request, reply) => {
  try {
    const userId = Helpers.extractUserId(request);
    const { markerId, streamId, ...rest } = request.payload;

    const stream = await Stream.findOne({ _id: streamId });
    if (!stream) throw new Error("Stream not found");

    const { title, start_time, end_time } = rest;
    const payload = {
      title,
      start_time: start_time,
      end_time: end_time,
    };
    await Clip.create(payload);
    const clipCreationPayload = {
      streamId: stream.streamId,
      start_time: start_time,
      input_video_url: stream.url,
    };

    // here I want to call the above api with `clipCreationPayload` payload
    return reply({
      status: true,
      message: "Clip has been sent.",
    });
  } catch (error) {
    logger.error(error);
    return reply({
      status: false,
      message: error.message,
    });
  }
};

const routeConfig = {
  method: "POST",
  path: "/second-route",
  config: {
    auth: "jwt",
    handler,
  },
};

Can I call an exported default function inside the same file?

I have this structure in my code:

export default async function () {
    someCode();
}

export async function someOtherFunction() {
    tryingToCallTheDefaultFunction();
}

How can I call the default function in the same file as default function?
I know that it is possible when using named default exports. Is there another way?

Thanks in advance!

CSV File Downloaded as true.txt When Programmatically Triggered in JavaScript

I’m encountering a peculiar issue with downloading .csv files programmatically in a web application. When I click on a presigned URL (pointing to an AWS S3 object) directly from the console log or navigate to it manually, the .csv file downloads correctly with the proper filename and extension. However, when I try to trigger the download programmatically using JavaScript, the file gets downloaded as true.txt instead.

Here’s the frontend code snippet:

const DownloadData = async () => {
    const token = localStorage.getItem("token");
    const backendUrl_fetchdata = `http://127.0.0.1:8000/fetch-data/`;

    try {
        const response = await axios.post(
            backendUrl_fetchdata,
            {
                // request payload
            },
            {
                headers: {
                    Authorization: `Token ${token}`,
                },
                withCredentials: true
            }
        );

        if (response.status === 200 && response.data.urls) {
            response.data.urls.forEach(({ url, filename: expectedFilename }) => {
                console.log("Downloading file from URL:", url);

                if (expectedFilename.endsWith('.csv')) {
                    // Attempt to download CSV
                    const link = document.createElement("a");
                    link.href = url;
                    link.setAttribute("download", expectedFilename);
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);
                }
            });
        }
    } catch (error) {
        console.error("Error fetching URLs:", error);
    }
};

Backend (Django):
The backend generates presigned URLs for the files stored in AWS S3. These URLs are sent to the frontend as part of the response.

Observations:

The console.log accurately prints the URL, and clicking it initiates
the correct download. Manually navigating to the URL also results in
the correct file being downloaded. When the download is triggered
programmatically, the browser downloads a true.txt file instead.

Questions:

  1. Why does the browser download the file as true.txt when the download is initiated programmatically, despite the URL being correct and the .csv file downloading correctly when accessed directly?
  2. How can I ensure that the .csv file is downloaded with the correct filename and extension when the download is triggered programmatically?

Any insights or solutions to this issue would be greatly appreciated!

POST request in a loop – oData arrives in the backend as duplicate (SAP Fiori)

Really need help to crack this nut. I’ve got a POST request in a loop, as you can see in the screenshot. The data is prepared correctly in the frontend but it seems to arrive at the backend as duplicated. Any idea why this line keeps creating the same entry?? I’ve tried pretty much everything I could find. Any help please?

Thank you so much!

enter image description here

Tried groupId and stopping batch processing but nothing worked

Image resize using quill-blot-formatter package prohibits the scrolling in the react-quill editor

I am using react-quill editor which supports image upload is accomplished by ‘formats/image’ from quill.

Quill editor doesn’t provide image resize option by default, so we are using the quill-blot-formatter package and register to Quill modules

Quill.register(‘modules/blotFormatter’, BlotFormatter);

It works with image resize but while doing so, it prohibits the scrolling effect of the Quill editor if the mouse focus is inside the resize window

Image resize prohibits editor scrolling

If the mouse focus/pointer outside the image resize then scrolling is working fine. I think somehow the event is not bubbling up to the ql-editor and it is stopped.

QuillEditor.js

import ReactQuill from 'react-quill';

const Quill = ReactQuill.Quill;
const Embed = Quill.import('blots/embed');
import BlotFormatter from 'quill-blot-formatter/dist/BlotFormatter';
import { CustomImage } from './CustomPlugins/CustomImage';

//to register uploaded image as blot
Quill.register(CustomImage, true);
// Register image resize
Quill.register('modules/blotFormatter', BlotFormatter);

<ReactQuill
  ref={editorRef}
  className={`w-full ${height} ${className} `}
  formats={formats}
  id={id}
  modules={modules(toolbarId)}
  theme="snow"
  value={state}
  onChange={handleChange}
      />

function modules(toolbarId) {
     return {
      blotFormatter: {
      specs: [CustomImageSpec], //register the custom spec
      align: {
        icons: alignmentStyles,
      },
    },
  };
}
CustomImageSpec.js

import DeleteIcon from '../../../assets/DeleteIcon.svg';
import { alignToolBar } from './helper';
import ImageSpec from 'quill-blot-formatter/dist/specs/ImageSpec';

// Custom image spec for blot formatter
// Adding delete icon to the blot toolbar on mount phase
export class CustomImageSpec extends ImageSpec {
  img;
  deleteIcon;

  constructor(formatter) {
    super(formatter);
    this.img = null;
    this.deleteIcon = this.createDeleteIcon();
  }

  createDeleteIcon() {
    const spanElement = document.createElement('span');
    const imgElement = document.createElement('img');
    imgElement.src = DeleteIcon;
    imgElement.alt = 'test image';
    const clsList = ['blot-formatter__toolbar-button', 'blot-delete-icon'];
    spanElement.classList.add(...clsList);
    spanElement.appendChild(imgElement);
    spanElement.style.cssText =
      'display: flex; align-items:center; justify-content:center; width: 24px; height: 24px; cursor:pointer; user-select:none; padding: 2px';
    spanElement.addEventListener('click', this.onDeleteIconClick);
    return spanElement;
  }

  init() {
    this.formatter.quill.root.addEventListener('click', this.onClick);
    this.formatter.quill.root.addEventListener('scroll', (e) => {
       this.formatter.repositionOverlay();
    });
  }

  getTargetElement() {
    return this.img;
  }

  onDeleteIconClick = () => {
    // Handle delete icon click
    if (this.img) {
      this.img.remove();
      this.formatter.hide();
    }
  };

  onHide() {
    this.img = null;
  }

  onClick = (event) => {
    const el = event.target;
    if (!el || el.tagName !== 'IMG') {
      return;
    }
    this.img = el;
    this.formatter.show(this);
    alignToolBar(this.formatter);
    this.formatter.overlay
      ?.getElementsByClassName('blot-formatter__toolbar')[0]
      ?.appendChild(this.deleteIcon);
  };
}

CustomImage.js

import { Quill } from 'react-quill';

// eslint-disable-next-line react-refresh/only-export-components
const BaseImage = Quill.import('formats/image');
// const BaseImage = Quill.import('blots/embed')
// eslint-disable-next-line react-refresh/only-export-components
const ATTRIBUTES = ['alt', 'height', 'width', 'style'];

export class CustomImage extends BaseImage {
  static formats(domNode) {
    return ATTRIBUTES.reduce(function (formats, attribute) {
      if (domNode.hasAttribute(attribute)) {
        formats[attribute] = domNode.getAttribute(attribute);
      }
      return formats;
    }, {});
  }
  format(name, value) {
    if (ATTRIBUTES?.indexOf(name) > -1) {
      if (value) {
        this.domNode.setAttribute(name, value);
      } else {
        this.domNode.removeAttribute(name);
      }
    } else {
      super.format(name, value);
    }
  }
}

//to register uploaded image as blot
Quill.register(CustomImage, true);

how can i retrieve the values i send using this javascript

<script>
    $(document).ready(function() {
    $('body').on("click", ".btn-theme", function() {
        var name = $(this).data("name").replace(/s/g, "_");
        var id = $(this).data("type");
        var price = $(this).data("price");

        window.location.href ='order.php?type=' + id + '&price=' + price + '&name=' + name;
    });
});
</script>

I make use of this JavaScript to send id, price and name to order page.
how can I retrieve those values at my order page.

How to retrieve carousel image and captions and opening it up as a modal upon click using Javascript

I am trying to implement a carousel that opens up the image with the associated caption in a modal when the user clicks on the image.

So far, I am able to open up the image but not able to retrieve the caption as the script only looks for attribute within the img tag. Is there a way to also retrieve the h5 and p tag within the carousel-caption div container and pass it so that the modal receives it?

<div id="carouselExampleCaptions" class="carousel slide">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
    <button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
    <button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://picsum.photos/id/1/200/300" class="d-block w-100" alt="">
      <div class="carousel-caption d-none d-md-block">
        <h5>First slide label</h5>
        <p>Some representative placeholder content for the first slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://picsum.photos/id/2/200/300" class="d-block w-100" alt="">
      <div class="carousel-caption d-none d-md-block">
        <h5>Second slide label</h5>
        <p>Some representative placeholder content for the second slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://picsum.photos/id/2/200/300" class="d-block w-100" alt="">
      <div class="carousel-caption d-none d-md-block">
        <h5>Third slide label</h5>
        <p>Some representative placeholder content for the third slide.</p>
      </div>
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

<!-- Modal -->
<div class="modal fade" id="gallery-modal" tabindex="-1">
  <div class="modal-dialog modal-dialog-centered modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <div class="modal-body">
         <img src="img/1.jpg" class="modal-img" alt="modal img">
      </div>
    </div>
  </div>
</div>

Javascript

document.addEventListener("click",function (e){
   if(e.target.classList.contains("d-block")){
      const src = e.target.getAttribute("src");
      document.querySelector(".modal-img").src = src;
      const myModal = new bootstrap.Modal(document.getElementById('gallery-modal'));
      myModal.show();
   }
 })

Login forbidden after upgrading Meteor version 2.2 to 2.4

Meteor version: 2.4
Node version: 14.x

After upgrading Meteor version 2.2 to 2.4 I face some issues. In the project, I used useraccounts:core and connected with that some other dependencies. After the upgrade my login design changed and when I try to log in it will show me the “Login forbidden” error. I am attaching the previous login design after upgrading the design.

PREVIOUS DESIGN:

enter image description here

CURRENT DESIGN:

enter image description here

Now if I use email rather than username it will be logged in but the home screen is blank. I am sure that logged in successfully because in local storage the desired details are stored.

Mobile keyboard not triggered using guacamole-common-js in browser

I’m working on a project that aims to render a RDP connection in a browser (mobile and desktop) using Apache Guacamole. For the UI, I’m using ReactJS and guacamole-common-js. Everything works as expected on both platforms, other than the keyboard not being triggered on mobile browser.

const GuacdPage = (props) => {
  const {connectionParam, onError, onStateChange, onSync} = props;

  const [guacd, setGuacd] = useState({});

  useEffect(() => {
    console.log('initial effect starting')
    renderDisplay();
  }, []);

  const renderDisplay = () => {
    const tunnel = new Guacamole.WebSocketTunnel("/api/ws");
    const client = new Guacamole.Client(tunnel);

    client.onerror = onError;
    client.onsync = onSync;
    client.onstatechange = onStateChange

    // Get display div from document
    const displayEle = document.getElementById("display");

    // Add client to display div
    const element = client.getDisplay().getElement();
    displayEle.appendChild(element);

    client.connect("connection=" + connectionParam);
    const display = client.getDisplay();

    const sink = new Guacamole.InputSink();
    displayEle.appendChild(sink.getElement());
    sink.focus();

    const keyboard = new Guacamole.Keyboard(sink.getElement());

    keyboard.onkeydown = (keysym) => {
      client.sendKeyEvent(1, keysym);
    };
    keyboard.onkeyup = (keysym) => {
      client.sendKeyEvent(0, keysym);
    };
    const mouse = new Guacamole.Mouse(element);

    mouse.onmousedown = mouse.onmouseup = function(mouseState) {
      sink.focus();
      client.sendMouseState(mouseState);
    };

    mouse.onmousemove = function(mouseState) {
      sink.focus();
      client.getDisplay().showCursor(false);
      mouseState.x = mouseState.x / display.getScale();
      mouseState.y = mouseState.y / display.getScale();
      client.sendMouseState(mouseState);
    };
    const touch = new Guacamole.Mouse.Touchscreen(element);

    touch.onmousedown = touch.onmousemove = touch.onmouseup = function(state) {
      client.sendMouseState(state);
    };
    window.addEventListener("resize", handleResize);

    return () => {
        client.disconnect()
        window.removeEventListener("resize", handleResize)
    }

  };

  const handleResize = () => {
    const width = document.body.offsetWidth
    const height = document.body.offsetHeight
    guacd.client.sendSize(width, height);
}

  return (
    <div>
      <div className="container">
        <div id="display" />
      </div>
    </div>
  );
};

export default GuacdPage;

I have tried two solutions:

  1. Using an InputSink
  2. Using an OnScreenKeyboard

The 2nd method renders a “list of keys” on screen with no effect, and the 1st does nothing – I think the issue has to do how the focus is being handled. I’m not sure if I need to be creating a dedicated input field for the input sink.

Any input would be greatly appreciated. Thanks

React retains local value inside method even after re-render

The below React code has a simple useState hook that updates the newName property. There is also a local variable localPageTwoCount that is incremented inside the updateName method.

import { useState } from "react";

function PageTwo() {

let [newName, setNewName] = useState("");
let localPageTwoCount = 0;

const updateName = () =>  {
    console.log("localPageTwoCount", localPageTwoCount)
    localPageTwoCount++;
    return setNewName("Name " + localPageTwoCount)
    
}

return <div>
    <h1>This content is from page2</h1>
    <div>newName {newName}</div>
    <div>localPageTwoCount {localPageTwoCount}</div>
    <button onClick={updateName}> Update Count </button>
    
</div>

}

export default PageTwo;

My understanding is that when setName is called it re-renders the component which re-initializes the variable localPageTwoCount, making localPageTwoCount always 0 in React.Dom. But the localPageTwoCount inside updateName method behaves weirdly it retains the incremented value and logs localPageTwoCount 1 for every 2 clicks.

This is how the console looks

enter image description here

Can anyone explain how is this possible.