-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rm like when not necessary
- Loading branch information
Showing
3 changed files
with
26 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
import AtpAgent, { RichText } from "@atproto/api"; | ||
import { messageExists, saveMessage, messageWrongExists } from "./redis"; | ||
import { saveMessage } from "./redis"; | ||
|
||
export const sendMessage = async ( | ||
convoId: string, | ||
message: RichText, | ||
agent: AtpAgent, | ||
taggedPost: string | ||
) => { | ||
try { | ||
const [sended, wrongMessage] = await Promise.all([ | ||
messageExists(taggedPost), | ||
messageWrongExists(taggedPost), | ||
]); | ||
if (sended || wrongMessage) { | ||
console.log(`Already sended ${taggedPost}`); | ||
return; | ||
} | ||
const proxy = agent.withProxy("bsky_chat", "did:web:api.bsky.chat"); | ||
await proxy.chat.bsky.convo.sendMessage({ | ||
convoId: convoId, | ||
message: { | ||
text: message.text, | ||
facets: message.facets, | ||
}, | ||
}); | ||
await saveMessage(taggedPost); | ||
} catch (error) { | ||
console.log("Error on send message:", error); | ||
} | ||
const proxy = agent.withProxy("bsky_chat", "did:web:api.bsky.chat"); | ||
await proxy.chat.bsky.convo.sendMessage({ | ||
convoId: convoId, | ||
message: { | ||
text: message.text, | ||
facets: message.facets, | ||
}, | ||
}); | ||
await saveMessage(taggedPost); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { messageExists, messageWrongExists } from "./redis"; | ||
|
||
export const shouldProcessMention = async (taggedPost: string) => { | ||
const [sended, wrongMessage] = await Promise.all([ | ||
messageExists(taggedPost), | ||
messageWrongExists(taggedPost), | ||
]); | ||
return sended || wrongMessage; | ||
}; |