Created
February 28, 2019 13:27
-
-
Save buddies2705/4dfd66aa30d387a676c94c48667b7a6c to your computer and use it in GitHub Desktop.
Gravatar Mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NewGravatar, UpdatedGravatar } from './types/Gravity/Gravity' | |
import { Gravatar } from './types/schema' | |
export function handleNewGravatar(event: NewGravatar): void { | |
let gravatar = new Gravatar(event.params.id.toHex()) | |
gravatar.owner = event.params.owner | |
gravatar.displayName = event.params.displayName | |
gravatar.imageUrl = event.params.imageUrl | |
gravatar.save() | |
} | |
export function handleUpdatedGravatar(event: UpdatedGravatar): void { | |
let id = event.params.id.toHex() | |
let gravatar = Gravatar.load(id) | |
if (gravatar == null) { | |
gravatar = new Gravatar(id) | |
} | |
gravatar.owner = event.params.owner | |
gravatar.displayName = event.params.displayName | |
gravatar.imageUrl = event.params.imageUrl | |
gravatar.save() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment