Leaked messages from a prison where 17 inmates died last year show staff laughing at beating inmates and joking about self-harm.