Birthday cake emoji for the chat room
This commit is contained in:
parent
09ba634556
commit
59338d510f
|
@ -66,8 +66,9 @@ func Landing() http.HandlerFunc {
|
||||||
|
|
||||||
// Are they logging into the chat room?
|
// Are they logging into the chat room?
|
||||||
var (
|
var (
|
||||||
intent = r.FormValue("intent")
|
intent = r.FormValue("intent")
|
||||||
isShy = currentUser.IsShy()
|
isShy = currentUser.IsShy()
|
||||||
|
birthday = r.FormValue("birthday") == "true" && currentUser.IsBirthday()
|
||||||
)
|
)
|
||||||
if intent == "join" {
|
if intent == "join" {
|
||||||
// Maintenance mode?
|
// Maintenance mode?
|
||||||
|
@ -114,6 +115,11 @@ func Landing() http.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Birthday cake emoji?
|
||||||
|
if birthday {
|
||||||
|
emoji = "🍰 It's my birthday!"
|
||||||
|
}
|
||||||
|
|
||||||
// Create the JWT claims.
|
// Create the JWT claims.
|
||||||
claims := Claims{
|
claims := Claims{
|
||||||
IsAdmin: currentUser.HasAdminScope(config.ScopeChatModerator),
|
IsAdmin: currentUser.HasAdminScope(config.ScopeChatModerator),
|
||||||
|
|
|
@ -606,6 +606,23 @@ func (u *User) GetDisplayAge() string {
|
||||||
return "n/a"
|
return "n/a"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsBirthday returns whether it is currently the user's birthday (+- a day for time zones).
|
||||||
|
func (u *User) IsBirthday() bool {
|
||||||
|
if u.Birthdate.IsZero() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Window of time to be valid.
|
||||||
|
var (
|
||||||
|
now, _ = time.Parse(time.DateOnly, time.Now().Format(time.DateOnly))
|
||||||
|
bday, _ = time.Parse(time.DateOnly, fmt.Sprintf("%d-%d-%d", now.Year(), u.Birthdate.Month(), u.Birthdate.Day()))
|
||||||
|
startDate = now.Add(-24 * time.Hour)
|
||||||
|
endDate = now.Add(24 * time.Hour)
|
||||||
|
)
|
||||||
|
|
||||||
|
return bday.Before(endDate) && bday.After(startDate)
|
||||||
|
}
|
||||||
|
|
||||||
// ProfileFieldIn checks if a substring is IN a profile field. Currently
|
// ProfileFieldIn checks if a substring is IN a profile field. Currently
|
||||||
// does a naive strings.Contains(), intended for the "here_for" field.
|
// does a naive strings.Contains(), intended for the "here_for" field.
|
||||||
func (u *User) ProfileFieldIn(field, substr string) bool {
|
func (u *User) ProfileFieldIn(field, substr string) bool {
|
||||||
|
|
|
@ -26,6 +26,24 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="block p-4">
|
<div class="block p-4">
|
||||||
|
{{if .CurrentUser.IsBirthday}}
|
||||||
|
<div class="notification is-success is-light content">
|
||||||
|
<h2>🎂 Happy birthday!</h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you would like, you may enter the chat room with a special 🍰 birthday cake emoji next to
|
||||||
|
your username instead of the usual country flag. This is totally optional and you may do this
|
||||||
|
by clicking the button <em>below</em> to enter the chat room:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="/chat?intent=join&birthday=true" class="button">
|
||||||
|
🍰 Join the Chat Room
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{if .IsShyUser}}
|
{{if .IsShyUser}}
|
||||||
<div class="notification is-danger is-light">
|
<div class="notification is-danger is-light">
|
||||||
<i class="fa fa-exclamation-triangle"></i> You have a <strong>Shy Account</strong> and you may not enter
|
<i class="fa fa-exclamation-triangle"></i> You have a <strong>Shy Account</strong> and you may not enter
|
||||||
|
|
Loading…
Reference in New Issue
Block a user