Test chat room flags some more
This commit is contained in:
parent
ece83a0b23
commit
001477de61
|
@ -71,17 +71,29 @@ func GetChatFlagEmoji(r *http.Request) (string, error) {
|
|||
return emoji, err
|
||||
}
|
||||
|
||||
var flags = []string{
|
||||
emoji,
|
||||
city.Country.IsoCode,
|
||||
// The components of text location part of the string.
|
||||
var flags = []string{}
|
||||
|
||||
// The country. Name or ISO code?
|
||||
if name, ok := city.Country.Names[city.Country.IsoCode]; ok {
|
||||
flags = append(flags, name)
|
||||
} else {
|
||||
flags = append(flags, city.Country.IsoCode)
|
||||
}
|
||||
|
||||
// Subdivisions (states)
|
||||
if len(city.Subdivisions) > 0 {
|
||||
for _, sub := range city.Subdivisions {
|
||||
flags = append(flags, sub.IsoCode)
|
||||
// Can we get its name?
|
||||
if name, ok := sub.Names[sub.IsoCode]; ok {
|
||||
flags = append(flags, name)
|
||||
} else {
|
||||
flags = append(flags, sub.IsoCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strings.Join(flags, " "), nil
|
||||
return emoji + " " + strings.Join(flags, ", "), nil
|
||||
}
|
||||
|
||||
// GetCity queries the GeoIP database for city information for an IP address.
|
||||
|
|
Loading…
Reference in New Issue
Block a user