add post validation

This commit is contained in:
RustamOper05 2024-01-17 12:31:41 +03:00
parent 892f607cd0
commit 8d90e22772

View file

@ -75,8 +75,18 @@ func GetAllPostsByUser(login string) []Post {
i := 1
n := getPostIndex(login)
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)
if post == nil {
panic("post not found")
}
i++
postsByUser = append(postsByUser, std.Deserialize(post.([]byte)).(Post))
}