fix: split workbench core mysql access
This commit is contained in:
@@ -396,7 +396,11 @@ func (s *Store) SaveCompletedFileUpload(ctx context.Context, file CompletedFileU
|
||||
if now.IsZero() {
|
||||
now = time.Now().UTC().Round(time.Millisecond)
|
||||
}
|
||||
_, err := s.db.ExecContext(ctx, `INSERT INTO im_fileuploads
|
||||
db := s.db
|
||||
if s.core != nil && s.core.db != nil {
|
||||
db = s.core.db
|
||||
}
|
||||
_, err := db.ExecContext(ctx, `INSERT INTO im_fileuploads
|
||||
(tenant_id,id,createdat,updatedat,userid,status,mimetype,size,etag,location)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,?)`,
|
||||
s.tenant(), file.ID, now, now, formatInt64(file.UserID), 1, file.MIMEType, file.Size, file.ETag, file.Location)
|
||||
|
||||
@@ -172,10 +172,13 @@ func (s *Store) WorkbenchModules(ctx context.Context, userID int64) ([]Workbench
|
||||
}
|
||||
|
||||
func (s *Store) MeetingUnreadCount(ctx context.Context, userID int64) (int, error) {
|
||||
if s.core == nil || s.core.db == nil {
|
||||
return 0, nil
|
||||
}
|
||||
var count int
|
||||
query := fmt.Sprintf(`SELECT COUNT(*) FROM %s
|
||||
WHERE tenant_id=? AND user_id=? AND read_at IS NULL AND event_type LIKE 'meeting.%%'`, tenantSystemNotificationsTable(s.tenant()))
|
||||
err := s.db.GetContext(ctx, &count, query, s.tenant(), userID)
|
||||
err := s.core.db.GetContext(ctx, &count, query, s.tenant(), userID)
|
||||
if isMissingTable(err) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user