fix(mysql): adapt tenant shared database fields
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//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"
|
||||
}
|
||||
Reference in New Issue
Block a user