store: normalize ids in telegram_file and add index
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"maunium.net/go/mautrix/bridgev2"
|
"maunium.net/go/mautrix/bridgev2"
|
||||||
@@ -96,7 +97,7 @@ func getLocationID(loc any) (locID store.TelegramFileLocationID) {
|
|||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unknown location type %T", location))
|
panic(fmt.Errorf("unknown location type %T", location))
|
||||||
}
|
}
|
||||||
return store.TelegramFileLocationID(id)
|
return store.TelegramFileLocationID(strings.TrimRight(id, "-"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transferer is a utility for downloading media from Telegram and uploading it
|
// Transferer is a utility for downloading media from Telegram and uploading it
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-- v0 -> v6 (compatible with v2+): Latest revision
|
-- v0 -> v7 (compatible with v2+): Latest revision
|
||||||
|
|
||||||
CREATE TABLE telegram_user_state (
|
CREATE TABLE telegram_user_state (
|
||||||
user_id BIGINT NOT NULL PRIMARY KEY,
|
user_id BIGINT NOT NULL PRIMARY KEY,
|
||||||
@@ -52,6 +52,8 @@ CREATE TABLE telegram_file (
|
|||||||
size BIGINT
|
size BIGINT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE INDEX telegram_file_mxc_idx ON telegram_file (mxc);
|
||||||
|
|
||||||
CREATE TABLE telegram_topic (
|
CREATE TABLE telegram_topic (
|
||||||
channel_id BIGINT NOT NULL,
|
channel_id BIGINT NOT NULL,
|
||||||
topic_id BIGINT NOT NULL,
|
topic_id BIGINT NOT NULL,
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- v7 (compatible with v2+): Add index and fix values in telegram_file
|
||||||
|
UPDATE telegram_file SET id=REPLACE(id, '-', '') WHERE id LIKE '%-';
|
||||||
|
CREATE INDEX telegram_file_mxc_idx ON telegram_file (mxc);
|
||||||
Reference in New Issue
Block a user