if (isReply) { if (inThread) { if (hasSameMembers) { // register new message in thread // possibly convert to room only if parent is channel } else { // create sub thread } } else if (inRoom) { if (isGroup) { if (hasSameMembers) { // register new message in group } else { // create thread } } else { // reply from channel if (messageInRoom == 1) { // was new channel transform to group // register new message in group } else if (sender == owner) { // correction from the original sender // leave in the same channel } else { // user response to announcement // create new thread } } } else { // transfer // todo test if members of transferred message are included } } else { if (inRoomByOwner) { // register message in room } else { // create room } }