38 lines
669 B
Go
38 lines
669 B
Go
//go:build mysql
|
|
// +build mysql
|
|
|
|
package mysql
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
t "github.com/tinode/chat/server/store/types"
|
|
)
|
|
|
|
func tenantFriendshipsTable(t.TenantID) string {
|
|
return "im_friendships"
|
|
}
|
|
|
|
func tenantMessagesTable(t.TenantID) string {
|
|
return "im_messages"
|
|
}
|
|
|
|
func tenantGroupMessagesTable(_ t.TenantID, month string) (string, bool) {
|
|
if !validShardMonth(month) {
|
|
return "", false
|
|
}
|
|
return fmt.Sprintf("im_group_messages_%s", month), true
|
|
}
|
|
|
|
func validShardMonth(month string) bool {
|
|
if len(month) != 6 {
|
|
return false
|
|
}
|
|
for i := range month {
|
|
if month[i] < '0' || month[i] > '9' {
|
|
return false
|
|
}
|
|
}
|
|
return month[4:] >= "01" && month[4:] <= "12"
|
|
}
|