add post validation
This commit is contained in:
parent
892f607cd0
commit
8d90e22772
1 changed files with 11 additions and 1 deletions
|
@ -75,8 +75,18 @@ func GetAllPostsByUser(login string) []Post {
|
||||||
i := 1
|
i := 1
|
||||||
n := getPostIndex(login)
|
n := getPostIndex(login)
|
||||||
for i < n+1 {
|
for i < n+1 {
|
||||||
post_key := storage.Get(ctx, login+"_p_"+std.Itoa10(i)).(string)
|
post_key := storage.Get(ctx, login+"_p_"+std.Itoa10(i))
|
||||||
|
if post_key == nil {
|
||||||
|
panic("post key not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
post_key = post_key.(string)
|
||||||
|
|
||||||
post := storage.Get(ctx, post_key)
|
post := storage.Get(ctx, post_key)
|
||||||
|
if post == nil {
|
||||||
|
panic("post not found")
|
||||||
|
}
|
||||||
|
|
||||||
i++
|
i++
|
||||||
postsByUser = append(postsByUser, std.Deserialize(post.([]byte)).(Post))
|
postsByUser = append(postsByUser, std.Deserialize(post.([]byte)).(Post))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue