Refactor: controller: consolidate getting the message type
... and use the proper type for the variable