mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Format code
This commit is contained in:
parent
eb4f88bc60
commit
0439e1f37a
@ -161,7 +161,8 @@ namespace Kyoo.Authentication
|
|||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
context.HttpContext.Items["PermissionGroup"]
|
context.HttpContext.Items["PermissionGroup"]
|
||||||
is Group group and not Group.None
|
is Group group
|
||||||
|
and not Group.None
|
||||||
)
|
)
|
||||||
_group = group;
|
_group = group;
|
||||||
else if (_group == Group.None)
|
else if (_group == Group.None)
|
||||||
|
@ -218,22 +218,24 @@ namespace Kyoo.Core.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return File.Open(
|
return File.Open($"/metadata/user/{userId}.webp", FileMode.Open);
|
||||||
$"/metadata/user/{userId}.webp",
|
|
||||||
FileMode.Open
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException) { }
|
catch (FileNotFoundException) { }
|
||||||
catch (DirectoryNotFoundException) { }
|
catch (DirectoryNotFoundException) { }
|
||||||
|
|
||||||
User user = await users.Value.Get(userId);
|
User user = await users.Value.Get(userId);
|
||||||
if (user.Email == null) throw new ItemNotFoundException();
|
if (user.Email == null)
|
||||||
|
throw new ItemNotFoundException();
|
||||||
using MD5 md5 = MD5.Create();
|
using MD5 md5 = MD5.Create();
|
||||||
string hash = Convert.ToHexString(md5.ComputeHash(Encoding.ASCII.GetBytes(user.Email))).ToLower();
|
string hash = Convert
|
||||||
|
.ToHexString(md5.ComputeHash(Encoding.ASCII.GetBytes(user.Email)))
|
||||||
|
.ToLower();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpClient client = clientFactory.CreateClient();
|
HttpClient client = clientFactory.CreateClient();
|
||||||
HttpResponseMessage response = await client.GetAsync($"https://www.gravatar.com/avatar/{hash}.jpg?d=404&s=250");
|
HttpResponseMessage response = await client.GetAsync(
|
||||||
|
$"https://www.gravatar.com/avatar/{hash}.jpg?d=404&s=250"
|
||||||
|
);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
return await response.Content.ReadAsStreamAsync();
|
return await response.Content.ReadAsStreamAsync();
|
||||||
}
|
}
|
||||||
@ -250,7 +252,8 @@ namespace Kyoo.Core.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete($"/metadata/user/{userId}.webp");
|
File.Delete($"/metadata/user/{userId}.webp");
|
||||||
} catch { }
|
}
|
||||||
|
catch { }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
using SKCodec codec = SKCodec.Create(image);
|
using SKCodec codec = SKCodec.Create(image);
|
||||||
|
@ -114,4 +114,3 @@ public class UserApi(ILibraryManager libraryManager, IThumbnailsManager thumbs)
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,13 +8,9 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(name: "logo_blurhash", table: "users");
|
||||||
name: "logo_blurhash",
|
|
||||||
table: "users");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(name: "logo_source", table: "users");
|
||||||
name: "logo_source",
|
|
||||||
table: "users");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -25,13 +21,15 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
table: "users",
|
table: "users",
|
||||||
type: "character varying(32)",
|
type: "character varying(32)",
|
||||||
maxLength: 32,
|
maxLength: 32,
|
||||||
nullable: true);
|
nullable: true
|
||||||
|
);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "logo_source",
|
name: "logo_source",
|
||||||
table: "users",
|
table: "users",
|
||||||
type: "text",
|
type: "text",
|
||||||
nullable: true);
|
nullable: true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ZodObject, ZodRawShape, z } from "zod";
|
import { ZodTypeAny, z } from "zod";
|
||||||
import { Account, AccountP } from "./accounts";
|
import { Account, AccountP } from "./accounts";
|
||||||
import { MMKV } from "react-native-mmkv";
|
import { MMKV } from "react-native-mmkv";
|
||||||
|
|
||||||
@ -46,10 +46,10 @@ export const setCookie = (key: string, val?: unknown) => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const readCookie = <T extends ZodRawShape>(
|
export const readCookie = <T extends ZodTypeAny>(
|
||||||
cookies: string | undefined,
|
cookies: string | undefined,
|
||||||
key: string,
|
key: string,
|
||||||
parser?: ZodObject<T>,
|
parser?: T,
|
||||||
) => {
|
) => {
|
||||||
if (!cookies) return null;
|
if (!cookies) return null;
|
||||||
const name = `${key}=`;
|
const name = `${key}=`;
|
||||||
|
@ -102,7 +102,7 @@ export const Avatar = forwardRef<
|
|||||||
alt={alt}
|
alt={alt}
|
||||||
width={size}
|
width={size}
|
||||||
height={size}
|
height={size}
|
||||||
{...css({ position: "absolute" }) as ImageProps}
|
{...(css({ position: "absolute" }) as ImageProps)}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user