treewide: separate user and channel namespaces
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
@@ -181,9 +181,10 @@ SELECT
|
||||
FROM reaction_old
|
||||
INNER JOIN message ON reaction_old.msg_mxid=message.mxid;
|
||||
|
||||
INSERT INTO telegram_access_hash (user_id, entity_id, access_hash)
|
||||
INSERT INTO telegram_access_hash (user_id, entity_type, entity_id, access_hash)
|
||||
SELECT
|
||||
user_old.tgid,
|
||||
CASE WHEN id < 0 THEN 'channel' ELSE 'user' END,
|
||||
CASE WHEN id < 0 THEN -id - 1000000000000 ELSE id END,
|
||||
hash
|
||||
FROM telethon_entities_old
|
||||
@@ -202,8 +203,11 @@ FROM telethon_update_state_old
|
||||
LEFT JOIN user_old ON user_old.mxid=session_id
|
||||
WHERE entity_id<>0 AND user_old.tgid IS NOT NULL;
|
||||
|
||||
INSERT INTO telegram_username (username, entity_id)
|
||||
SELECT username, CASE WHEN id < 0 THEN -id - 1000000000000 ELSE id END
|
||||
INSERT INTO telegram_username (username, entity_type, entity_id)
|
||||
SELECT
|
||||
username,
|
||||
CASE WHEN id < 0 THEN 'channel' ELSE 'user' END,
|
||||
CASE WHEN id < 0 THEN -id - 1000000000000 ELSE id END
|
||||
FROM telethon_entities_old
|
||||
WHERE username<>''
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
@@ -289,11 +289,15 @@ func legacyProvContacts(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
contactsMap := map[int64]*legacyContactInfo{}
|
||||
for _, contact := range contacts {
|
||||
id, err := ids.ParseUserID(contact.UserID)
|
||||
peerType, id, err := ids.ParseUserID(contact.UserID)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to parse user id")
|
||||
exhttp.WriteJSONResponse(w, http.StatusInternalServerError, resp.WithError("M_UNKNOWN", fmt.Sprintf("Failed to parse user id: %v", err)))
|
||||
return
|
||||
} else if peerType != ids.PeerTypeUser {
|
||||
log.Err(err).Msg("Unexpected peer type")
|
||||
exhttp.WriteJSONResponse(w, http.StatusInternalServerError, resp.WithError("M_UNKNOWN", fmt.Sprintf("Unexpected peer type: %s", peerType)))
|
||||
return
|
||||
}
|
||||
if contact.UserInfo != nil {
|
||||
contact.Ghost.UpdateInfo(ctx, contact.UserInfo)
|
||||
|
||||
@@ -108,7 +108,7 @@ func main() {
|
||||
"v0.16.0",
|
||||
m.LegacyMigrateWithAnotherUpgrader(
|
||||
legacyMigrateRenameTables, legacyMigrateCopyData, 16,
|
||||
upgrades.Table, "telegram_version", 1,
|
||||
upgrades.Table, "telegram_version", 2,
|
||||
),
|
||||
true,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user