1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Enable premium, add custom avatar saving support to complete #10

This commit is contained in:
NG (Graham)
2025-08-13 17:36:44 -04:00
parent 2642767a27
commit a8692b2839
16 changed files with 178 additions and 17 deletions

View File

@@ -9,12 +9,16 @@ pub(super) fn custom_avatar_upload_handler() -> CustomAvatarHandler {
CustomAvatarHandler
}
async fn do_save(params: ParameterTable<()>, _user: &crate::UserTy) -> Result<ParameterTable, i16> {
async fn do_save(params: ParameterTable<()>, user: &crate::UserTy) -> Result<ParameterTable, i16> {
let mut params = params.to_dict();
//let user_info = user.user()?;
if let Some(Typed::Bytes(image)) = params.remove(&IMG_PARAM_KEY) {
if let Some(Typed::Int(format)) = params.remove(&FORMAT_PARAM_KEY) {
log::debug!("Got custom avatar ({}B) with format {}", image.vec.len(), format);
if format != 0 {
log::warn!("Got non-jpg format {} for custom avatar, this was assumed to be impossible", format);
}
user.user()?.save_custom_avatar(image.vec).await?;
// TODO actually save image
/*let info = oj_rc_core::persist::user::AvatarInfo {
avatar_id: 0,

View File

@@ -14,7 +14,7 @@ pub(super) fn premium_remaining_provider() -> SimpleFunc<15, crate::UserTy, impl
params.insert(HOURS_PARAM_KEY, Typed::Int(0));
params.insert(MINUTES_PARAM_KEY, Typed::Int(0));
params.insert(SECONDS_PARAM_KEY, Typed::Int(0));
params.insert(LIFETIME_PARAM_KEY, Typed::Bool(false));
params.insert(LIFETIME_PARAM_KEY, Typed::Bool(true));
Ok(params.into())
})
}