mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 11:34:04 +00:00 
			
		
		
		
	Can delete account image
This commit is contained in:
		@@ -101,6 +101,8 @@ export const Routes : Route[] = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	{path: "/settings/upload_account_image", cb: (h) => SettingsController.UploadAccountImage(h)},
 | 
						{path: "/settings/upload_account_image", cb: (h) => SettingsController.UploadAccountImage(h)},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{path: "/settings/delete_account_image", cb: (h) => SettingsController.DeleteAccountImage(h)},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Friends controller
 | 
						// Friends controller
 | 
				
			||||||
	{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
 | 
						{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -232,4 +232,14 @@ export class SettingsController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		h.success();
 | 
							h.success();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Delete account account image
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param h Request handler
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static async DeleteAccountImage(h: RequestHandler) {
 | 
				
			||||||
 | 
							await AccountImageHelper.Delete(h.getUserId());
 | 
				
			||||||
 | 
							h.success();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -40,6 +40,21 @@ export class AccountImageHelper {
 | 
				
			|||||||
		writeFileSync(this.GetPathMetadataFile(userID), path.replace("avatars/", ""));
 | 
							writeFileSync(this.GetPathMetadataFile(userID), path.replace("avatars/", ""));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Delete (remove) a user account image
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param userID Target user ID
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static async Delete(userID: number) {
 | 
				
			||||||
 | 
							const currInfo = await this.Get(userID);
 | 
				
			||||||
 | 
							if(currInfo.hasImage) {
 | 
				
			||||||
 | 
								unlinkSync(currInfo.sysPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Delete meta file
 | 
				
			||||||
 | 
								unlinkSync(this.GetPathMetadataFile(userID));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Get the content of the file associated to the user account image, if any
 | 
						 * Get the content of the file associated to the user account image, if any
 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user