Remove username normalization
We don't have one unified username format, it can be a name, a phone number or a user id. Therefore we can't put it into a unified format without eventually breaking things.
This commit is contained in:
parent
51bb79947c
commit
048ef56eee
1 changed files with 1 additions and 42 deletions
|
@ -1026,47 +1026,6 @@ static void tgprpl_convo_closed (PurpleConnection * gc, const char *who) {
|
|||
debug ("tgprpl_convo_closed()\n");
|
||||
}
|
||||
|
||||
static char *strdup_replace (char *str, const char *replace, char *with) {
|
||||
char **splitted = g_strsplit (str, replace, -1);
|
||||
char *joined = g_strjoinv ("", splitted);
|
||||
g_strfreev (splitted);
|
||||
return joined;
|
||||
}
|
||||
|
||||
static const char *tgprpl_normalize_phone_number (const PurpleAccount *account, const char *phone) {
|
||||
|
||||
// remove all special characters
|
||||
char *a = g_strdup(phone);
|
||||
char *b = strdup_replace (a, " ", "");
|
||||
char *c = strdup_replace (b, "/", "");
|
||||
char *normalized = strdup_replace (c, "-", "");
|
||||
g_free (b);
|
||||
g_free (a);
|
||||
g_free (c);
|
||||
|
||||
if (strlen (normalized) >= 22 ||
|
||||
strlen (normalized) < 5) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (normalized[0] != '+') {
|
||||
char *fixed = g_strdup_printf ("+%s", normalized);
|
||||
g_free (normalized);
|
||||
normalized = fixed;
|
||||
}
|
||||
|
||||
regex_t exp;
|
||||
if (regcomp (&exp, "\\+[0-9]+$", REG_EXTENDED) != 0) {
|
||||
warning ("Regex invalid");
|
||||
return NULL;
|
||||
}
|
||||
if (regexec (&exp, normalized, 0, 0, 0) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
static void tgprpl_set_buddy_icon (PurpleConnection * gc, PurpleStoredImage * img) {
|
||||
debug ("tgprpl_set_buddy_icon()\n");
|
||||
|
||||
|
@ -1146,7 +1105,7 @@ static PurplePluginProtocolInfo prpl_info = {
|
|||
tgprpl_rename_group,
|
||||
NULL, // buddy_free
|
||||
tgprpl_convo_closed,
|
||||
tgprpl_normalize_phone_number,
|
||||
NULL, // normalize
|
||||
tgprpl_set_buddy_icon,
|
||||
NULL, // remove_group
|
||||
NULL, // get_cb_real_name
|
||||
|
|
Loading…
Add table
Reference in a new issue