protected static function export_digest_data(int $userid, \stdClass $forum, int $maildigest) {
        if (null !== $maildigest) {
            // The user has a specific maildigest preference for this forum.
            $a = (object) [
                'forum' => format_string($forum->name, true),
            ];

            switch ($maildigest) {
                case 0:
                    $a->type = get_string('emaildigestoffshort', 'mod_forum');
                    break;
                case 1:
                    $a->type = get_string('emaildigestcompleteshort', 'mod_forum');
                    break;
                case 2:
                    $a->type = get_string('emaildigestsubjectsshort', 'mod_forum');
                    break;
            }

            writer::with_context(\context_module::instance($forum->cmid))
                ->export_metadata([], 'digestpreference', $maildigest,
                    get_string('privacy:digesttypepreference', 'mod_forum', $a));

            return true;
        }

        return false;
    }