Handle t.me/username as username in search

This commit is contained in:
Eduard Kuzmenko 2022-01-26 17:36:52 +04:00
parent b15c51d5d1
commit da405f647d

View File

@ -910,6 +910,18 @@ export class AppUsersManager {
});
} */
public searchContacts(query: string, limit = 20) {
// handle 't.me/username' as 'username'
const entities = RichTextProcessor.parseEntities(query);
if(entities.length && entities[0].length === query.trim().length && entities[0]._ === 'messageEntityUrl') {
try {
const url = new URL(RichTextProcessor.wrapUrl(query).url);
const path = url.pathname.slice(1);
if(path) {
query = path;
}
} catch(err) {}
}
return apiManager.invokeApiCacheable('contacts.search', {
q: query,
limit