Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mention Mapping #230

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

feat: Mention Mapping #230

wants to merge 4 commits into from

Conversation

ralmn
Copy link
Collaborator

@ralmn ralmn commented Nov 10, 2024

This convert mention to right social platform account

Example of mention-mapping.xxxx.json file :

[
    {"twitter": "ralmn45", "mastodon": "[email protected]", "bluesky": "ralmn.fr"},
    {"twitter": "louisgrasset", "mastodon": "[email protected]", "bluesky": "louisgrasset.bsky.social"}
]

src/configuration/configuration.ts Outdated Show resolved Hide resolved
src/helpers/tweet/__tests__/split-tweet-text.spec.ts Outdated Show resolved Hide resolved
src/helpers/tweet/__tests__/split-tweet-text.spec.ts Outdated Show resolved Hide resolved
Comment on lines +29 to +49
let tweetText = text!;

if (mentions != null) {
for (const tweetMention of mentions) {
const mapped = mentionsMapping.find(
(mapping) => tweetMention.username == mapping.twitter,
);
if (mapped == null) {
continue;
}
const newMention =
platform === Platform.MASTODON ? mapped!.mastodon : mapped!.bluesky;
if (newMention != null) {
tweetText = tweetText.replaceAll(
`@${tweetMention.username}`,
`@${newMention}`,
);
}
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on my phone, so this comment won't be that helpful, but my feeling is that conditions and typing are a bit too complicated /flacky (but again, I don't have the ide to actually see all the typings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants