feat: Customize url preview user agent #1372
Labels
No labels
Blocked
Bug
Cherry-picking
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
Support
To-Merge
Wont fix
old/ci/cd
old/rust
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
continuwuation/continuwuity!1372
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "trashpanda/continuwuity:trashpanda/url-preview-ua"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This pull request implements a config option to set the user agent of the URL preview reqwest client, which can help with embed generator services like FxEmbed which expect certain strings in user agents to determine that the requestor is not a user attempting to navigate to the requested website. If those certain strings aren't found, they usually issue a redirect to the requested page.
Fixes: #1364
Pull request checklist:
mainbranch, and the branch is named something other thanmain.myself, if applicable. This includes ensuring code compiles.
@ -52,0 +53,4 @@config.url_preview_user_agent.as_ref().map_or(conduwuit::version::user_agent(), |ua| ua.as_str()),I considered making this into a block expression to only set the user agent when the config option is set, but it felt less concise. Duplicating the user agent set in the
base()function feels weird, though.Code looks good to me. Perhaps the default user agent could be updated to include the magic
botsubstring mentioned in !1364?Won't be able to come back to this until tonight, but I'll get that change in! I'll implement the one Jade suggested here.
This is an important fix i'd like to get in! Have you added the
.tomlsection yet?I honestly think making it configurable could be a bit overkill.
If you guys are happy to fix the thumbnail, preview, or whichever relevant endpoints with the
embedbotsuffix section, that would be a simple compromise perhapsWIP: feat: customize url preview user agentto WIP: feat: Customize url preview user agentWIP: feat: Customize url preview user agentto feat: Customize url preview user agent5564865a00975d33bddf975d33bddf564edcb1f4Should be good to merge now. Don't forget to build your changes, both to test it locally and to generate the config file.
@ -1699,0 +1699,4 @@/// User agent that is used specifically when fetching url previews.////// default: "continuwuity/<version> (bot; +https://continuwuity.org)"pub url_preview_user_agent: Option<String>,Does this need to be an
Option<String>if it has a default?Currently, yes. I imagine the default updating with the actual version is preferred, as long as people don't have it explicitly set? Unless we want to do a little templating and replace any instances of
<version>with theversion_ua()string?It's generated outside of the config. Could have probably been done the other way (moving the init into the config default function), but doesn't matter now
@trashpanda wrote in #1372 (comment):
Ah, that makes sense.
oh, this needs a new fragment
564edcb1f426aac1408e