Updating array from a document with updateOne

I’m using MongoDB with Java & I’m wondering how I would update an array as in an add/remove from the array messages in a document, so far I have something like this (bare in mind the method updateMessage is part-code part-pseudo-code). This is the “code” I’m using here. This is my JSON data (2 documents from a collection) here.