mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 11:34:04 +00:00 
			
		
		
		
	Can get account image settings
This commit is contained in:
		@@ -97,6 +97,8 @@ export const Routes : Route[] = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	{path: "/settings/update_password", cb: (h) => SettingsController.UpdatePassword(h)},
 | 
						{path: "/settings/update_password", cb: (h) => SettingsController.UpdatePassword(h)},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{path: "/settings/get_account_image", cb: (h) => SettingsController.GetAccountImageSettings(h)},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Friends controller
 | 
						// Friends controller
 | 
				
			||||||
	{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
 | 
						{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,16 @@ import { GeneralSettings, UserPageStatus, SupportedLanguages, LangSettings, Secu
 | 
				
			|||||||
import { removeHTMLNodes, checkURL, fixEncoding } from "../utils/StringUtils";
 | 
					import { removeHTMLNodes, checkURL, fixEncoding } from "../utils/StringUtils";
 | 
				
			||||||
import { checkVirtualDirectoryAvailability, VirtualDirType } from "../utils/VirtualDirsUtils";
 | 
					import { checkVirtualDirectoryAvailability, VirtualDirType } from "../utils/VirtualDirsUtils";
 | 
				
			||||||
import { AccountHelper } from "../helpers/AccountHelper";
 | 
					import { AccountHelper } from "../helpers/AccountHelper";
 | 
				
			||||||
 | 
					import { AccountImageVisibilityLevel } from "../entities/AccountImage";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * API account image visibility levels
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					const ACCOUNT_IMAGE_VISIBLITY_LEVELS = {};
 | 
				
			||||||
 | 
					ACCOUNT_IMAGE_VISIBLITY_LEVELS[AccountImageVisibilityLevel.EVERYONE] = "open";
 | 
				
			||||||
 | 
					ACCOUNT_IMAGE_VISIBLITY_LEVELS[AccountImageVisibilityLevel.COMUNIC_USERS] = "public";
 | 
				
			||||||
 | 
					ACCOUNT_IMAGE_VISIBLITY_LEVELS[AccountImageVisibilityLevel.FRIENDS] = "friends";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class SettingsController {
 | 
					export class SettingsController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -190,4 +200,19 @@ export class SettingsController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		h.success();
 | 
							h.success();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Get account image settings
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param h Request handler
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static async GetAccountImageSettings(h: RequestHandler) {
 | 
				
			||||||
 | 
							const imageInfo = (await UserHelper.GetUserInfo(h.getUserId())).accountImage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							h.send({
 | 
				
			||||||
 | 
								has_image: imageInfo.hasImage,
 | 
				
			||||||
 | 
								image_url: imageInfo.url,
 | 
				
			||||||
 | 
								visibility: ACCOUNT_IMAGE_VISIBLITY_LEVELS[imageInfo.level]
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -33,6 +33,14 @@ export class AccountImage {
 | 
				
			|||||||
		return AccountImage.urlForFile(this.path);
 | 
							return AccountImage.urlForFile(this.path);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Check out whether the user has an account image
 | 
				
			||||||
 | 
						 * or if it is the default account image
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						get hasImage() : boolean {
 | 
				
			||||||
 | 
							return this.path.length > 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static get errorURL() : string {
 | 
						static get errorURL() : string {
 | 
				
			||||||
		return this.urlForFile(errorAccountImage);
 | 
							return this.urlForFile(errorAccountImage);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user