@@ -25,6 +25,7 @@ type UserCustomIconsApi struct {
2525 ApiUsingConfig
2626 ApiUsingDuplicateChecker
2727 icons * services.UserCustomIconService
28+ users * services.UserService
2829}
2930
3031// Initialize a user custom icons api singleton instance
4041 container : duplicatechecker .Container ,
4142 },
4243 icons : services .UserCustomIcons ,
44+ users : services .Users ,
4345 }
4446)
4547
@@ -67,6 +69,20 @@ func (a *UserCustomIconsApi) CustomIconListHandler(c *core.WebContext) (any, *er
6769// CustomIconUploadHandler saves a new custom icon for current user
6870func (a * UserCustomIconsApi ) CustomIconUploadHandler (c * core.WebContext ) (any , * errs.Error ) {
6971 uid := c .GetCurrentUid ()
72+ user , err := a .users .GetUserById (c , uid )
73+
74+ if err != nil {
75+ if ! errs .IsCustomError (err ) {
76+ log .Errorf (c , "[user_custom_icons.CustomIconUploadHandler] failed to get user, because %s" , err .Error ())
77+ }
78+
79+ return nil , errs .ErrUserNotFound
80+ }
81+
82+ if user .FeatureRestriction .Contains (core .USER_FEATURE_RESTRICTION_TYPE_UPLOAD_CUSTOM_ICON ) {
83+ return nil , errs .ErrNotPermittedToPerformThisAction
84+ }
85+
7086 form , err := c .MultipartForm ()
7187
7288 if err != nil {
@@ -260,6 +276,20 @@ func (a *UserCustomIconsApi) CustomIconDeleteHandler(c *core.WebContext) (any, *
260276 }
261277
262278 uid := c .GetCurrentUid ()
279+ user , err := a .users .GetUserById (c , uid )
280+
281+ if err != nil {
282+ if ! errs .IsCustomError (err ) {
283+ log .Errorf (c , "[user_custom_icons.CustomIconDeleteHandler] failed to get user, because %s" , err .Error ())
284+ }
285+
286+ return nil , errs .ErrUserNotFound
287+ }
288+
289+ if user .FeatureRestriction .Contains (core .USER_FEATURE_RESTRICTION_TYPE_UPLOAD_CUSTOM_ICON ) {
290+ return nil , errs .ErrNotPermittedToPerformThisAction
291+ }
292+
263293 err = a .icons .DeleteCustomIcon (c , uid , iconDeleteReq .Id )
264294
265295 if err != nil {
0 commit comments