Fix mastodon api conversion for new note id type

This commit is contained in:
Laura Hausmann 2023-07-02 02:36:56 +02:00 committed by ThatOneCalculator
parent b90c824f0c
commit 6c29a2ae01
No known key found for this signature in database
GPG key ID: 8703CACD01000000

View file

@ -13,18 +13,19 @@ pub enum IdConvertType {
#[napi] #[napi]
pub fn convert_id(in_id: String, id_convert_type: IdConvertType) -> napi::Result<String> { pub fn convert_id(in_id: String, id_convert_type: IdConvertType) -> napi::Result<String> {
println!("converting id: {}", in_id);
use IdConvertType::*; use IdConvertType::*;
match id_convert_type { match id_convert_type {
MastodonId => { MastodonId => {
let mut out: i64 = 0; let mut out: i128 = 0;
for (i, c) in in_id.to_lowercase().chars().rev().enumerate() { for (i, c) in in_id.to_lowercase().chars().rev().enumerate() {
out += num_from_char(c)? as i64 * 36_i64.pow(i as u32); out += num_from_char(c)? as i128 * 36_i128.pow(i as u32);
} }
Ok(out.to_string()) Ok(out.to_string())
} }
CalckeyId => { CalckeyId => {
let mut input: i64 = match in_id.parse() { let mut input: i128 = match in_id.parse() {
Ok(s) => s, Ok(s) => s,
Err(_) => { Err(_) => {
return Err(Error::new( return Err(Error::new(