Studio checksum from name. Default image

This commit is contained in:
WithoutPants
2019-08-21 15:48:36 +10:00
parent 043d073bcf
commit 20662532d8
7 changed files with 22 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
mutation StudioCreate(
$name: String!,
$url: String,
$image: String!) {
$image: String) {
studioCreate(input: { name: $name, url: $url, image: $image }) {
...StudioData

View File

@@ -12,7 +12,7 @@ input StudioCreateInput {
name: String!
url: String
"""This should be base64 encoded"""
image: String!
image: String
}
input StudioUpdateInput {

View File

@@ -12,8 +12,18 @@ import (
)
func (r *mutationResolver) StudioCreate(ctx context.Context, input models.StudioCreateInput) (*models.Studio, error) {
// generate checksum from studio name rather than image
checksum := utils.MD5FromString(input.Name)
var imageData []byte
var err error
if input.Image == nil {
input.Image = &models.DefaultStudioImage
}
// Process the base 64 encoded image string
checksum, imageData, err := utils.ProcessBase64Image(input.Image)
_, imageData, err = utils.ProcessBase64Image(*input.Image)
if err != nil {
return nil, err
}

View File

@@ -2235,7 +2235,7 @@ input StudioCreateInput {
name: String!
url: String
"""This should be base64 encoded"""
image: String!
image: String
}
input StudioUpdateInput {
@@ -8699,7 +8699,7 @@ func (ec *executionContext) unmarshalInputStudioCreateInput(ctx context.Context,
}
case "image":
var err error
it.Image, err = ec.unmarshalNString2string(ctx, v)
it.Image, err = ec.unmarshalOString2string(ctx, v)
if err != nil {
return it, err
}

View File

@@ -255,7 +255,7 @@ type StudioCreateInput struct {
Name string `json:"name"`
URL *string `json:"url"`
// This should be base64 encoded
Image string `json:"image"`
Image *string `json:"image"`
}
type StudioDestroyInput struct {

View File

@@ -13,3 +13,5 @@ type Studio struct {
CreatedAt SQLiteTimestamp `db:"created_at" json:"created_at"`
UpdatedAt SQLiteTimestamp `db:"updated_at" json:"updated_at"`
}
var DefaultStudioImage string = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4wgVBQsJl1CMZAAAASJJREFUeNrt3N0JwyAYhlEj3cj9R3Cm5rbkqtAP+qrnGaCYHPwJpLlaa++mmLpbAERAgAgIEAEBIiBABERAgAgIEAEBIiBABERAgAgIEAHZuVflj40x4i94zhk9vqsVvEq6AsQqMP1EjORx20OACAgQRRx7T+zzcFBxcjNDfoB4ntQqTm5Awo7MlqywZxcgYQ+RlqywJ3ozJAQCSBiEJSsQA0gYBpDAgAARECACAkRAgAgIEAERECACAmSjUv6eAOSB8m8YIGGzBUjYbAESBgMkbBkDEjZbgITBAClcxiqQvEoatreYIWEBASIgJ4Gkf11ntXH3nS9uxfGWfJ5J9hAgAgJEQAQEiIAAERAgAgJEQAQEiIAAERAgAgJEQAQEiL7qBuc6RKLHxr0CAAAAAElFTkSuQmCC"

View File

@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */
// Generated in 2019-08-20T18:32:35+10:00
// Generated in 2019-08-21T15:05:29+10:00
export type Maybe<T> = T | undefined;
export interface SceneFilterType {
@@ -197,7 +197,7 @@ export interface StudioCreateInput {
url?: Maybe<string>;
/** This should be base64 encoded */
image: string;
image?: Maybe<string>;
}
export interface StudioUpdateInput {
@@ -411,7 +411,7 @@ export type SceneUpdateSceneUpdate = SceneDataFragment;
export type StudioCreateVariables = {
name: string;
url?: Maybe<string>;
image: string;
image?: Maybe<string>;
};
export type StudioCreateMutation = {
@@ -1819,7 +1819,7 @@ export function useSceneUpdate(
>(SceneUpdateDocument, baseOptions);
}
export const StudioCreateDocument = gql`
mutation StudioCreate($name: String!, $url: String, $image: String!) {
mutation StudioCreate($name: String!, $url: String, $image: String) {
studioCreate(input: { name: $name, url: $url, image: $image }) {
...StudioData
}