Skip to content

Commit

Permalink
searching mastodon handle when using a nostr account automatically lo…
Browse files Browse the repository at this point in the history
…ads the bridged profile
  • Loading branch information
ghobs91 committed Mar 15, 2024
1 parent 8aab907 commit 5154a9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/components/search-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ const SearchForm = forwardRef((props, ref) => {
q: query,
};
if (instance === "ditto.pub") {
let convertedQuery = query;
if (query.indexOf("@") === 0) {
convertedQuery = query.replace("@", "")
}
(async () => {
convertedQuery = query.replace("@", "_at_");
const matchedMostrHexPing = await fetch(`https://mostr.pub/.well-known/nostr.json?name=${convertedQuery}`, {method: "get"});
const matchedMostrHexPingResponse = await matchedMostrHexPing.json();
if (matchedMostrHexPingResponse && matchedMostrHexPingResponse["names"]) {
const matchedMostrHex = matchedMostrHexPingResponse["names"][convertedQuery]
const dittoProfileCall = await fetch(`https://ditto.pub/api/v1/accounts/${matchedMostrHex}`, {method: "get"});
const dittoProfileCallResponse = await dittoProfileCall.json();
location.hash = `/${instance}/a/${dittoProfileCallResponse.id}`;
}
})();
console.log(`instance === "ditto.pub"`)
} else if (instance === "skybridge.fly.dev") {
if (query.indexOf("@") === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/welcome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Welcome() {
<big>
<b>
<Link to="/login" class="button">
Log in
Get Started
</Link>
</b>
</big>
Expand Down

0 comments on commit 5154a9d

Please sign in to comment.