move attachment type logic into common service